I'm using jax-rs and adding entity for being marshalled in Jetty by JAXRSOutInterceptor, but JSON output is being modified with additional empty property which looks like this: "$": ""
The JSONProvider is created and configured as here:
JSONProvider jsonProvider = new JSONProvider();
jsonProvider.setConvertTypesToStrings(true);
jsonProvider.setIgnoreNamespaces(true);
jsonProvider.setIgnoreMixedContent(true);
jsonProvider.setUnmarshallAsJaxbElement(true);
providers.add(jsonProvider);
It is also being marshalled to XML which uses namespaces but I don't want them in JSON output and input.
The object that is being marshalled is similar to this:
@XmlRootElement(name="myObject1")
@XmlAccessorType(XmlAccessType.FIELD)
@SuppressWarnings("serial")
public class MyObject1 implements Serializable {
MyObject2 a;
MyObject2 b;
MyObject2 c;
// includes getters, setters, hashCode, equals, toString,
}
When MyObject2 is:
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@SuppressWarnings("serial")
public class MyObject2 implements Serializable {
String x;
String y;
List<String> z;
// includes getters, setters, hashCode, equals, toString,
}
The rest output is as following:
{
"myObject1": {
"a": {
"x": "value1",
"y": "value2",
"z": "value3",
"$": ""
},
"$": ""
}
}
How do I get rid of the ending "$": "" I read that the Jettison (which is the default JSONProvider implementation that I am using) is by default will represent properties mapped with @XmlValue as '$'s but there's no property ?
Is that caused by implementing Serializable?