3

When I started project I went with GSON as most completed and with a good backing.

I feel now that it is not performing very well. So, let's say when I load an array of 200 items (objects) from web service - it will take like 5 seconds to parse it out into object array on my Nexus S. On Emulator it is even more pronounced. In this case I like emulator slowness as it shows all this bad spots very well.

Now that my app is pretty much solid - I'm looking into different ways to do what I need to do and maybe save on install size. I had to bake GSON into my app with custom namespace because of HTC issues.

Michele La Ferla
  • 6,775
  • 11
  • 53
  • 79
katit
  • 17,375
  • 35
  • 128
  • 256

3 Answers3

4

Comparing json parser libraries.

Big File Results enter image description here

Small Files Results

enter image description here

Choosing which library to use on the merit of parsing speed comes down to your environment then.

  • If you have an environment that deals often or primarily with big JSON files, then Jackson is your library of interest. GSON struggles the most with big files.
  • If your environment primarily deals with lots of small JSON requests, such as in a micro services or distributed architecture setup, then GSON is your library of interest. Jackson struggles the most with small files.
  • If you end up having to often deal with both types of files, JSON.simple came in a very close 2nd place in both tests, making it a good workhorse for a variable environment. Neither Jackson nor GSON
    perform as well across multiple files sizes

    http://blog.takipi.com/the-ultimate-json-library-json-simple-vs-gson-vs-jackson-vs-json/

Yurii Bulan
  • 143
  • 1
  • 1
  • 7
3

Have you tried the org.json parser?

MattP
  • 1,920
  • 1
  • 15
  • 22
az4dan
  • 651
  • 2
  • 10
  • 30
  • I upvoted this, because I have used it and it is light and fast. But before you throw out GSON keep in mind it handles a lot of validation and error handling. You will probably need to implement these yourself, so by the ime you finish with all that validation and checking you may not see a big differnce. – Plastic Sturgeon Nov 10 '11 at 23:51
3

I've gotten fairly significant performance improvements by switching from GSON to Jackson in past projects.

kabuko
  • 36,028
  • 10
  • 80
  • 93
  • 2
    The current performance test results at https://github.com/eishay/jvm-serializers/wiki show Jackson to be 8 times faster than Gson, when binding to string input/output. – Programmer Bruce Nov 11 '11 at 21:15
  • Nice charts. When I changed over it was so much faster that I didn't bother to measure the difference. Good to see some numbers that match up. – kabuko Nov 11 '11 at 21:28