Friday, April 20th, 2007
Charlie Hubbard has released Flexjson, a lightweight JSON library for Java. Most JSON serializers mimic object serialization libraries and try to serialize the entire object graph from the object being turned into JSON. This causes problems when you want a connected object model on your server, but you can’t send that object model to the client because the serialization library will try to send the entire object graph. This is terrible for performance, causes most JSON libraries to blow up if they encounter circular references, makes it difficult to follow good OO practices, and makes it nearly impossible to use libraries such as Hibernate. Other JSON libraries require you to create a lot of boiler plate code to translate your object representation into a JSON object.
Flexjson tries to solve both of these problems by using a DSL approach to sending JSON. You don’t have to create lots of boiler plate code or modify your object model to make it work.
- return new JSONSerializer().include("hobbies", "favoriteMovies").serialize(person);
- return new JSONSerializer().exclude("password").include("hobbies").serialize(person);
Posted by Dion Almaer at 7:34 am