As you said, the two classes you have to create are :
data class Summary(val rows: List<List<Any>>)
data class Root(val summary: Summary)
Then to have the Root
object from a json
you have to create the adapter as follows
val moshi = Moshi.Builder().build()
val adapter = moshi.adapter(Root::class.java)
val root = adapter.fromJson(json)
Edit
As the error message says
Type is not directly supported by 'Parcelize'. Annotate the parameter type with '@RawValue
What it is saying is that not all types can be serialized using Parcel
, and therefore cannot be used directly with @Parcelize
, so that's why it recommends you to use @RawValue
.
The @RawValue
annotation is used to indicate that the annotated parameter should be treated as a raw value by the compiler. When used with @Parcelize
, it tells the compiler to not generate any serialization or deserialization code for the annotated parameter.
You should add @RawValue
to the attribute that is Any
.
In your example
data class Summary(@RawValue val rows: List<List<Any>>)
Ref:
How to parcel value with type any using parcelize
Rawvalue annotation is not applicable to target value parameter
>, )
– Ekanath May 08 '23 at 13:12