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
What steps will reproduce the problem?
public void testLargeGsonMapRoundTrip() throws Exception {
Map<Long, Long> original = Maps.newHashMap();
for (long i = 0; i < 50000; i++) {
original.put(i, i + 1);
}
Gson gson = new Gson();
String json = gson.toJson(original);
Type longToLong = new TypeToken<Map<Long, Long>>(){}.getType();
gson.fromJson(json, longToLong);
}
What is the expected output?
Gson should not recurse when parsing map entries. Parsing JSON is not that
hard, so I suggest not using Javacc.
What do you see instead?
com.google.gson.JsonParseException: Failed parsing JSON source:
java.io.StringReader@186d484 to Json
at com.google.gson.JsonParser.parse(JsonParser.java:61)
at com.google.gson.Gson.fromJson(Gson.java:443)
at com.google.gson.Gson.fromJson(Gson.java:396)
...
Caused by: java.lang.StackOverflowError
at
com.google.gson.JsonParserJavacc.jj_3R_5(JsonParserJavacc.java:449)
at
com.google.gson.JsonParserJavacc.jj_3R_4(JsonParserJavacc.java:456)
at
com.google.gson.JsonParserJavacc.jj_3R_2(JsonParserJavacc.java:443)
at
com.google.gson.JsonParserJavacc.jj_3_1(JsonParserJavacc.java:462)
at
com.google.gson.JsonParserJavacc.jj_2_1(JsonParserJavacc.java:428)
at
com.google.gson.JsonParserJavacc.JsonNumber(JsonParserJavacc.java:276)
at
com.google.gson.JsonParserJavacc.JsonValue(JsonParserJavacc.java:213)
at com.google.gson.JsonParserJavacc.Pair(JsonParserJavacc.java:112)
at
com.google.gson.JsonParserJavacc.Members(JsonParserJavacc.java:95)
at
com.google.gson.JsonParserJavacc.Members(JsonParserJavacc.java:99)
...
What version of the product are you using? On what operating system?
1.4 (in google3)
Original issue reported on code.google.com by skybr...@google.com on 9 Mar 2010 at 7:44
The text was updated successfully, but these errors were encountered:
I have the same problem. My Input is a 18MB json file, which has basically the
structure of Map<String, <Map, <String, Map<String, String>>>>
(I 'm not at liberty to provide the file)
There are only few keys on first level, so each "value" is quite large
Original comment by CptMa...@googlemail.com on 4 May 2010 at 9:26
Original issue reported on code.google.com by
skybr...@google.com
on 9 Mar 2010 at 7:44The text was updated successfully, but these errors were encountered: