@JsonClass(generateAdapter = true)
fails when class has field with type Array<Array<T>>
with default
#1862
Labels
@JsonClass(generateAdapter = true)
fails when class has field with type Array<Array<T>>
with default
#1862
Hello!
When testing Moshi CodeGen, I found a weird issue: when a class has a field with type
Array<Array<Something>>
with a default value, the generated adapter fails to find the correct constructor to create the class instance and deserialization fails withNoSuchMethodException
Here you can find a code snippet replicating the problem:
Since the JSON doesn't provide the
nestedArray
value, the generated adapter tries to retrieve the synthetic constructor, but probably uses the wrong type when doing so.By replacing
ReflectArray.newInstance(KotlinArray::class.java,0).javaClass
with a simpleArray<Array<String>>::class.java
, everything works properly.As a temporary workaround, using
Array<List<T>>
instead ofArray<Array<T>>
works correctly.Additional notes
Platform: Android 14
Moshi library version: 1.15.1
The text was updated successfully, but these errors were encountered: