rendering JSON String as JSON Using JAXB within jersey

By : epeleg

Given a class like this:

public class MyClass {
    private Boolean flag1;
    private String json;

Can I add an annotation that will cause the JSON to become part of the rendered JSON without being escaped as a string?

For example, if the object has flag1=true and json="{"a":5}" I want to get:


instead of:

By : epeleg


You can write your own marshaller to do so.

By : Amareswar

You can use a Provider to change default behaviour of JSONJAXBContext. See

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException; 

import com.sun.jersey.api.json.JSONConfiguration;
import com.sun.jersey.api.json.JSONJAXBContext;

public class CustomWoodwingOutputJSONContextProvider implements ContextResolver
By : dometec

This video can help you solving your question :)
By: admin