This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Java to JSON Writer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Java to JSON Writer" Watch "Java to JSON Writer" New topic
Author

Java to JSON Writer

Chris Baron
Ranch Hand

Joined: Mar 21, 2003
Posts: 1049
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

Joined: Jan 10, 2002
Posts: 61761
    
  67

I've been using Google's Gson library quite successfully.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Chris Baron
Ranch Hand

Joined: Mar 21, 2003
Posts: 1049
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
Marshal

Joined: Mar 22, 2005
Posts: 42916
    
  68
...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

Joined: Mar 21, 2003
Posts: 1049
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java to JSON Writer