I am parsing JSON and am having difficulty with one structure that can have one of three forms. In my case it could be zero-dimensional, one-dimensional or two-dimensional. Is there some way I can inspect the JSON on the fly to determine which one it is? Or perhaps consume it anyway and work out what it is afterwards.
The structures look like this and can be embedded in other structures.
"details":{
"Product":"A zero-dimensional Product"
},
"details":{
"Product":"A one-dimensional Product",
"Dimensions": [ "Size" ],
"Labels": [ "XS", "S", "M", "L" ]
},
"details":{
"Product":"A two-dimensional Product",
"Dimensions": [ "Size", "Fit" ],
"Labels": [[ "XS", "S", "M", "L" ],[ "26", "28", "30", "32" ]]
}
What I may be looking for is a generic class that Jackson will always match with.
Something like translating:
{
"SomeField": "SomeValue",
...
"details":{
...
}
}
Into:
class MyClass {
String SomeField;
...
AClass details;
}
Is there a class AClass
I can define that could be a universal recipient for any JSON structure or array?