This is the example of JSON I am having
filter : [
{ category: [] } ,
{ sub-category: [] } ,
{ brand: [] } ,
{ color: [] }
]
Note that the labels "category,subcategory..." may vary dynamically
How do I parse this JSON using Moshi ?
Decode it as a Map<String, Object>
. The map keys will be your JSON’s values. You can get that adapter like so:
Type map = Types.newParameterizedType(Map.class, String.class, Object.class);
JsonAdapter<Map<String, Object>> adapter = moshi.adapter(map);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With