mention that KotlinJsonAdapterFactory validates (#439)

See #438 for the use case. The documentation was not accurate enough IMO. Thus, mention that KotlinJsonAdapterFactory is required for validation.
This commit is contained in:
Robert Stoll
2018-02-18 04:17:42 +01:00
committed by Jesse Wilson
parent a6d31ba0b4
commit a00860ee1d

View File

@@ -474,7 +474,7 @@ public final class BlackjackHand {
### Kotlin Support ### 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. Add the KotlinJsonAdapterFactory last to allow other installed Kotlin type factories to be used, since factories are called in order. Kotlin classes work with Moshi out of the box. However, you need to add the `KotlinJsonAdapterFactory` if you want to activate the validation for non-nullable properties. Add it last to allow other installed Kotlin type factories to be used, since factories are called in order.
```kotlin ```kotlin
val moshi = Moshi.Builder() val moshi = Moshi.Builder()
// Add any other JsonAdapter factories. // Add any other JsonAdapter factories.
@@ -482,6 +482,9 @@ val moshi = Moshi.Builder()
.build() .build()
``` ```
If you need to annotate your Kotlin classes with an `@Json` annotation or otherwise, you need to add `KotlinJsonAdapterFactory` as well. In both cases you have to add `moshi-kotlin` as dependency (see below).
Download Download
-------- --------