• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java to JSON Writer

 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i'm looking for something where i can build up a large object hierachy (tree) in Java and write it out to JSON.
I've found XStream so far but i'm not totally satisfied with the default converters for Java Maps.
Before start writing my own converters, could anyone recommend another good Libary/Framework for this task?

Thanks Chris

P.S. i put my question in this forum because it's Ajax related
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been using Google's Gson library quite successfully.
 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,
Gson converts Maps to JSON objects. That's exactly what i was looking for. My problem with XStream is that it writes map entries to Arrays "mymap":["key","value"].

The way to chain the config methods with GsonBuilder is very nice.


Meanwhile i also found Stringtree JSON. It's only 13 KB and Jim Yingst is mentioned at the bottom of the page.
I'll evaluate them both.
Thanks a lot
Chris
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and Jim Yingst is mentioned ...

Not to mention that the library was written by Frank Carver, who ranks as a Sheriff here at JavaRanch! The library is in use as part of this very forum software, amongst other places.
 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:
...and Jim Yingst is mentioned ...

Not to mention that the library was written by Frank Carver, who ranks as a Sheriff here at JavaRanch! The library is in use as part of this very forum software, amongst other places.

Interesting. But i never came across Frank here, sorry.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic