简体   繁体   中英

Stackoverflow while using gson api's

I am getting stackoverflow error while deserializing java class.

Code

Gson gson = gsonBuilder.create();
Type listType = new TypeToken<List<StorageEntity>>() {}.getType();
List<StorageEntity> logObj = gson.fromJson (dbDocument, listType);

When I do gson.fromJson (dbDocument, listType), I am getting below mentioned stack trace.

   java.lang.StackOverflowError
        at com.google.gson.SimpleCharStream.GetImage(SimpleCharStream.java)
        at   com.google.gson.JsonParserTokenManager.jjFillToken(JsonParserTokenManager.java)

I have google it and idea that gson is not able to parse long string. Help me to resolve the issue.

Problem is something like this

http://code.google.com/p/google-gson/issues/detail?id=96

but I didn't found any answer.

Check if the object you are trying to deserialize have a circular reference. If yes, there will be an infinite loop.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM