RESTEasy uses Jettison JSON library to map JAXB annotation object to and from JSON. In this tutorial, we show you how to convert an JAXB annotated object into JSON format and return it back to client.
- JAXB Bridge is a bridge (JAXB 1.0 API implementation) to JiBX and other (in the future) XML-to-objects binding parsers, and its includes implementation with Apache commons-pool managed pool of parsers, to avoid costly instantiation of parsers in server environment.
- I create an XML dump file with JAXB, then i go through several transformations and arrive at a XML file that is in a format i desire. Now i want to convert this XML File that is properly escaped and encoded into a JSON file using JAXB.
RESTEasy uses Jettison JSON library to map JAXB annotation object to and from JSON. In this tutorial, we show you how to convert an JAXB annotated object into JSON format and return it back to client. Create an object, annotate with JAXB. Why using XML provider? No worry, later you will use.
You may also interest to read this RESTEasy + Jackson example.
1. RESTEasy + JAXB + Jettison
To use JSON in RESTEasy, you need following dependencies.
File : pom.xml

2. JAXB XML Provider
Create an object, annotate with JAXB. Why using XML provider? No worry, later you will use @BadgerFish to convert it into JSON format.

3. JAX-RS
To return a JSON file format, annotate the service method with @BadgerFish and @Produces('application/json').
RESTEasy will handle the JSON conversion automatically.
4. Demo
When URI pattern “/json/movie/get” is requested, following JSON file will be returned.