I have the following problem: I need to convert incoming JSON to Java objects, however, I don't always get the same incoming object (the format of the messages is varying). Sometimes it is a list, with custom elements:
[ 12, [100, 100, 100] ]
and sometimes it is an object:
{ key: 'value' .. }
I also need to convert the list to an object, not a list.
However, I know the format of the possible objects, but I cannot determine which one I get before I could parse it. What would be a good technique to map these to Java objects? Trying to parse with each object type and catching the formatting exceptions, or something else?