• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java to JSON Writer

 
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic