You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 11, 2023. It is now read-only.
I didn't see a built-in way to handle top-level arrays, e.g.:
[
{
"name": "Jorge",
"faveNumber": 4
},
{
...
}
]
Our current solution is to iterate through the array, making calls to the appropriate JsonHelper type for each object. Not a big deal really, but we'd need to duplicate this for each kind of model that's in a top-level array, since I don't see a way to generalize this into a helper method (anyone else?).
List<Video> videos = new LinkedList<Video>();
if (parser.nextToken() == JsonToken.START_ARRAY) {
while (parser.nextToken() != JsonToken.END_ARRAY) {
Video video = Video__JsonHelper.parseFromJson(parser);
videos.add(video);
}
}
Maybe JsonHelper types could know how to serialize/deserialize arrays of their model types. Something like:
public static final List<MyModel> parseFromJsonArray(JsonParser jp)