1

I have a big PoJo, which translates into a 45 MB JSON string. I am using Jackson, and the writeValueAsString method is taking more than 10–15 minutes to generate it.

If I generate a chunk of it, everything works reasonably quickly.

I looked at Gson metrics and it seems slower than Jackson.

How could I speed it up?

Code is very straight-forward:

String jsonString = mapper.writeValueAsString(value);
Joost
  • 10,333
  • 4
  • 55
  • 61
Sandeep Kaul
  • 2,957
  • 2
  • 20
  • 36
  • 3
    It can be useful: http://stackoverflow.com/questions/29836666/jackson-writevalueasstring-too-slow – ROMANIA_engineer Jan 08 '16 at 14:55
  • 3
    Any profiler results? – Dragan Bozanovic Jan 08 '16 at 15:15
  • 45Mb of json that's a beast.. –  Jan 08 '16 at 15:30
  • 2
    45MB doesn't sound 'plain old' to me! – Ben Thurley Jan 08 '16 at 15:32
  • 1
    At that file size, you should be streaming instead of working with strings. – ssube Jan 08 '16 at 16:12
  • 1
    `I have a big PoJo, which translates into a 45 MB JSON string` -- you're doing it wrong. Sorry but thats reality. Split that thing into (many) objects which get SELECTED individually - you may save vast amounts of data that way. – specializt Jan 08 '16 at 17:16
  • @DraganBozanovic, No profiler results yet. @specializt You mind explaining `you may save vast amounts of data that way` part. I didn't understand that. Trying to stream it now, maybe that would help. – Sandeep Kaul Jan 09 '16 at 03:40
  • thats easy : 45MB JSON data (very) likely includes unneeded data, simply select your NECESSARY data and transfer it chunkwise. Whats not to understand? You probably should'nt write software if you cant split up data packets ... thats pretty much programming basics. – specializt Jan 09 '16 at 15:26

0 Answers0