Probably a bit similar to this: deserializing json with arrays and also I'm following on from this: Jackson multiple objects and huge json files
The json I have is pretty big so simplified it goes something like this:
{ "foo"="bar", "x"="y", "z"=[{"stuff"="stuff"}, {"more"="stuff"}, ...], ... }
I have code that looks like this:
for (Iterator<Map> it = new ObjectMapper().readValues(new JsonFactory().createJsonParser(in), Map.class); it.hasNext();) {
doSomethingWith(it.next());
}
This works nicely at iterating over the objects in the file and I can get any value I like from the object I'm in. Works fine, but the array just comes back as an ArrayList of objects. So I have to do something like:
ArrayList z = (ArrayList) it.next().get("z");
for (Object o : z) {
// Run mapper on o.
// Do stuff.
}
I'm sure this would work, but it seems a bit messy to me. Is there a better way?