users@jersey.java.net

[Jersey] JSON inside POJO

From: Pierre Radermecker <pradermecker_at_yahoo.ca>
Date: Wed, 17 Aug 2011 15:29:30 -0700 (PDT)

Hi,

I have a serialization problem using Jersey 1.8.


I have a POJO that have one JSONObject attribute. The complete POJO needs to be serialized as JSON:


@XmlRootElement(name = "location")
public class Pojo implements Serializable {

    @XmlElement
    String name;

    @XmlElement
    JSONObject input;
    }
}

I receive the JSON input from another source (stream of bytes) and just need to use it (with no conversion)


The attribute "JSONObject" does not do what I want. If I use plain JAXB, I have got a null as the "input" value. If I set the property:
"com.sun.jersey.api.json.POJOMappingFeature" to true, I have a error saying there is no Serializer for JSONObject.


Using a String as the type is not an option. I have tried to simply use an array of bytes but without success.

Thanks for your help.

PierR