Hi,
I'm facing with the following issue:
I'm trying to unmarshal the JSON data received from web server using this
approach:
****************
ClientResponse responseJ =
server.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
//Get the entity of the response
String textEntityJ = (String)responseJ.getEntity(String.class);
JSONJAXBContext contextJson = null;
JSONUnmarshaller unmarshallerJson = null;
MyClass myClassJson = null;
//built JSONConfiguration based on mapped notation
contextJson = new JSONJAXBContext(JSONConfiguration.natural().build(),
MyClass.class);
unmarshallerJson = contextJson.createJSONUnmarshaller();//create JSON
Unmarshaller
myClassJson = unmarshallerJson.unmarshalFromJSON(new
StringReader(textEntityJ), MyClass.class);
***********
Even I get the data in the 'textEntityJ' in the format
{"version":["abb.123","xyz.456"]} the unmarshaller returns always MyClass
object with empty List ( myClassJson.getVersion().size = 0).
MyClass structure:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"version"
})
@XmlRootElement(name = "versions")
public class MyClass {
protected List version;
public List getVersion() {
if (version == null) {
version = new ArrayList();
}
return this.version;
}
}
What could be wrong? The same issue I'm facing with XML approach. I receive
data (as String) in the XML format, but unmarshaller failes in case when
Java bean contains LIST object.
Thanks in advance for your help,
Jairo
--
View this message in context: http://jersey.576304.n2.nabble.com/JSON-XML-unmarshaller-problem-tp6269059p6269059.html
Sent from the Jersey mailing list archive at Nabble.com.