So I have been looking around and I am not sure exactly how to handle this. I am parsing JSON that looks like this
{
"foo1" : { /* data I want */ },
"foo2" : { /* data I want */ },
"foo3" : { /* data I want */ },
...
}
Since I am trying to go through a large file I am using a stream. What I have right now is
gson = new GsonBuilder().create();
JsonReader jReader = new JsonReader(new InputStreamReader(getResources()
.openRawResource(R.raw.all_sets_x), "UTF-8"));
while (jReader.hasNext() && jReader.peek() != JsonToken.END_DOCUMENT) {
Set set = gson.fromJson(jReader, Set.class);
sets.add(set);
}
My issue is I want to skip the foo, and just read the { /* data I want */ }. I don't know offhand what all the different foos I may get. When I try to skip it skips the outer braces, but when I beginObject it errors on a string inside the braces with the data I want. I am sure I am likely missing something simple, but for the life of me I am not sure. I looked at trying to use the beginObject to make a json object and parse that using gson, but I was unsucessful there as well. Thanks for the help!