Skip to content
Advertisement

Jackson deserialise JSON with many dynamic nodes

I’m trying to deserialize a JSON file with the format of

JavaScript

But I don’t want to create a class for each language (thousands) so I wrote a custom LanguageDeserializer which gives me back the List<Language> that I want

JavaScript

I have a parent class to wrap the results:

JavaScript

So when I try and use it

JavaScript

The languages list is always empty.

Can I do this without needing the LanguageDeserializer or how do I make it work?

Advertisement

Answer

Yeah was clearly overthinking it. As @chrylis suggested a Map was the right direction to go in.

Simple as:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement