Closed GoogleCodeExporter closed 9 years ago
tried following code.. which was more efficient but it also crashes for more
objects.
final Writer writer = new StringWriter();
try
{
json.writeJSONString(writer);
}
catch ( final IOException e )
{
if ( QOCCompileConstants.LOGGING )
{
LOG.log(Level.ERROR, "IO error" + e.getMessage());
}
}
return writer.toString();
Original comment by vishalghadge
on 7 Nov 2011 at 7:25
Please make sure you that you allocate sufficient memory for JVM, or use the
streaming approach (what you mentioned in the comment):
http://code.google.com/p/json-simple/wiki/EncodingExamples#Example_2-4_-_Encode_
a_JSON_array_-_Using_List_and_streaming
Please note that a StringWriter still stores JSON output in the memory. Please
use something like FileWriter or your own writer implementation.
Original comment by fangyid...@gmail.com
on 29 Nov 2011 at 2:50
With respect, I don't think this is really a bug with json.simple; trying to
create a String that's too big to fit in available memory by any means will
cause the same problem.
Original comment by jon.cham...@gmail.com
on 10 Aug 2013 at 3:49
Original issue reported on code.google.com by
vishalghadge
on 7 Nov 2011 at 7:22