From a00860ee1dbb8fec7651307a62355873b27a580b Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sun, 18 Feb 2018 04:17:42 +0100 Subject: [PATCH] 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. --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7dbcc10..0b751ae 100644 --- a/README.md +++ b/README.md @@ -474,7 +474,7 @@ 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. 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 val moshi = Moshi.Builder() // Add any other JsonAdapter factories. @@ -482,6 +482,9 @@ val moshi = Moshi.Builder() .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 --------