I have an api that can have its answer in XML or Json. To analyze these results, I created the only object that I want to populate for both json and xml. The problem is that my XML parser seems to be deserializing XML in Json in a slightly different format.
In the middle of my answer is a nested array when I parse JSON, it looks like this:
"buckets":[ {"bucket":{"name":"soup","priority":10}}, {"bucket":{"name":"clams","priority":13}}],
And when I parse my XML into JSON, it looks like this
"buckets":{"bucket":[ {"priority":"10","name":"soup"}, {"priority":"13","name":"clams"}]},
My only object created to store this date has private buckets; Which json handler handles fine and the xml parsing throws an exception.
I parse both the object and myObject = mapper.readValue (SomeObject.get (0), myObject.class)
Json rugs work fine, but xml doesn't. I either have to parse the XML in the same format as json, or tell, possibly with annotations, to see the buckets correctly.
I am viewing my XML for json using this JSONObject jsonObject = XML.toJSONObject (cValue);
source share