Convert JSON to Kotlin classes.

Hi all,

I have a chunk of json from here (https://world.openfoodfacts.org/api/v0/product/5010358111810.json), that I need to be able to parse.

I wrote a quick prototype in C# where I simply pasted the JSON in to Visual Studio and it converts the json into C# classes.

I realise that you can’t do that in Android Studio and I tried an online json–>Kotlin class converter tool, which appeared to do the job…until I imported them into Android Studio.

It didn’t like some of the names it created, so I set about changing them manually, then realised that when it comes to deserialising it, the deserializer won’t know what the names are to match.

How do you all go about creating the classes for a JSON string this size?

Failing that, is it possible to convert it to a generic type and iterate around the result?

submitted by /u/dchurch2444
[link] [comments]