Out of memory exception in gson.fromJson()

后端 未结 4 804
醉话见心
醉话见心 2021-01-04 21:21

I use the following code for converting Json string(strWebserviceResult) to my Object:

EntMyClass entMyClass = gson.fromJson(strWebserviceResult,EntMyClass.c         


        
4条回答
  •  温柔的废话
    2021-01-04 21:47

    Please, read the answer from the author of gson - here

    And my 5 cents:

            JsonReader r = null;
            try {
                Reader reader = new BufferedReader(new InputStreamReader(is));
                r = new JsonReader(reader);
                result = gson.fromJson(r, clazz);
            } finally {
                if (null != r) {
                    r.close();
                }
            }
    

提交回复
热议问题