Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/JakeWharton/retrofit2-kotlinx-serialization-converter
A Retrofit 2 Converter.Factory for Kotlin serialization.
https://github.com/JakeWharton/retrofit2-kotlinx-serialization-converter
Last synced: 12 days ago
JSON representation
A Retrofit 2 Converter.Factory for Kotlin serialization.
- Host: GitHub
- URL: https://github.com/JakeWharton/retrofit2-kotlinx-serialization-converter
- Owner: JakeWharton
- License: apache-2.0
- Archived: true
- Created: 2018-01-08T04:56:36.000Z (almost 7 years ago)
- Default Branch: trunk
- Last Pushed: 2024-03-19T11:35:01.000Z (8 months ago)
- Last Synced: 2024-09-27T04:21:55.470Z (about 1 month ago)
- Language: Kotlin
- Homepage:
- Size: 383 KB
- Stars: 1,042
- Watchers: 15
- Forks: 60
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-kotlin - retrofit2-kotlinx-serialization-converter - A Retrofit 2 Converter.Factory for Kotlin serialization. (Libraries)
README
# Kotlin Serialization Converter
A Retrofit 2 `Converter.Factory` for [Kotlin serialization](https://github.com/Kotlin/kotlinx.serialization/).
**DEPRECATED** This has moved into Retrofit as a first-party converter. See [here](https://github.com/square/retrofit/tree/trunk/retrofit-converters/kotlinx-serialization) for info.
## Usage
Add a converter factory when building your `Retrofit` instance using the `asConverterFactory`
extension function:```kotlin
val contentType = "application/json".toMediaType()
val retrofit = Retrofit.Builder()
.baseUrl("https://example.com/")
.addConverterFactory(Json.asConverterFactory(contentType))
.build()
```Response body types (e.g., `Call`) and `@Body` types (e.g., `@Body user: User`) will now use
the supplied serializer.Because Kotlin serialization is so flexible in the types it supports, these converters assume
that they can handle all types. If you are mixing this converter with another, you must add this
instance _last_ to allow the other converters a chance to see their types.## Download
Gradle:
```kotlin
implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0")
```Maven:
```xmlcom.jakewharton.retrofit
retrofit2-kotlinx-serialization-converter
1.0.0```
Snapshots of the development version are available in
[Sonatype's `snapshots` repository](https://oss.sonatype.org/content/repositories/snapshots/).# License
Copyright 2018 Jake Wharton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.