Merge pull request #336 from Jawnnypoo/patch-1
Add moshi-kotlin documentation
This commit is contained in:
commit
b4ad3b9789
1 changed files with 26 additions and 1 deletions
27
README.md
27
README.md
|
@ -472,6 +472,14 @@ public final class BlackjackHand {
|
|||
}
|
||||
```
|
||||
|
||||
### Kotlin Support
|
||||
|
||||
Kotlin classes work with Moshi out of the box, with the exception of annotations. If you need to annotate your Kotlin classes with an `@Json` annotation or otherwise, you will need to use the `moshi-kotlin` artifact, and set up Moshi to use its converter factory:
|
||||
```kotlin
|
||||
val moshi = Moshi.Builder()
|
||||
.add(KotlinJsonAdapterFactory())
|
||||
.build()
|
||||
```
|
||||
|
||||
Download
|
||||
--------
|
||||
|
@ -488,6 +496,18 @@ or Gradle:
|
|||
```groovy
|
||||
compile 'com.squareup.moshi:moshi:1.5.0'
|
||||
```
|
||||
and for additional Kotlin support:
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.squareup.moshi</groupId>
|
||||
<artifactId>moshi-kotlin</artifactId>
|
||||
<version>1.5.0</version>
|
||||
</dependency>
|
||||
```
|
||||
or Gradle:
|
||||
```groovy
|
||||
compile 'com.squareup.moshi:moshi-kotlin:1.5.0'
|
||||
```
|
||||
|
||||
Snapshots of the development version are available in [Sonatype's `snapshots` repository][snap].
|
||||
|
||||
|
@ -504,7 +524,12 @@ If you are using ProGuard you might need to add the following options:
|
|||
@com.squareup.moshi.* <methods>;
|
||||
}
|
||||
```
|
||||
|
||||
Additional rules are needed if you are using the Kotlin artifact:
|
||||
```
|
||||
-keepclassmembers class kotlin.Metadata {
|
||||
public <methods>;
|
||||
}
|
||||
```
|
||||
|
||||
License
|
||||
--------
|
||||
|
|
Loading…
Reference in a new issue