Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The Kotlin Moshi adapter returns null when the library throws a JsonDataException because Moshi's default behavior when it encounters invalid JSON is to return null. This behavior can be customized by providing a custom JSON adapter or by using Moshi's lenient mode. In lenient mode, Moshi will attempt to parse the JSON even if it contains errors, but it may produce unexpected results. Generally, it's better to fix the underlying JSON data to avoid JsonDataException errors rather than relying on lenient mode or custom adapters to handle them.