Showing posts with label Jettison. Show all posts
Showing posts with label Jettison. Show all posts

April 15, 2011

JAXB and JSON via Jettison - Namespace Example

In a previous post I described how Jettison can be leveraged by a JAXB implementation to produce/consume JSON.  A reader correctly pointed out that I did not describe how to handle namespaces.  Since JSON does not support namespaces you would not normally include them in your mappings.  However if you wanted to map your object model to both JSON and XML with namespaces, this post will demonstrate how it can be done.

April 12, 2011

JAXB and JSON via Jettison

JAXB implementations (Metro, EclipseLink MOXy, Apache JaxMe, etc) provide an easy means of converting objects to/from XML.  There is a library called Jettison that exposes access to JSON messages via the StAX API that a JAXB implementation can use to convert objects to/from JSON.  This library is being leveraged by a number of JAX-RS implementations.  In this post I'll demonstrate its use in a standalone example.