java - Jackson empty xml array deserialization -
i have incoming xml recurly service list of transactions. it's empty , looks this:
<transactions type="array"> </transactions>
i need deserialize using jackson. i've tried next mapping
@xmlrootelement(name = "transactions") public class transactionobjectlistresponse extends arraylist<transactionobjectresponse> { }
where transactionobjectresponse class each transaction. works fine non-empty collections, fails when no transactions came. next message appears:
java.lang.illegalstateexception: missing name, in state: end_array @ com.fasterxml.jackson.dataformat.xml.deser.fromxmlparser.getcurrentname(fromxmlparser.java:310) @ com.fasterxml.jackson.databind.deser.beandeserializer.deserializefromobject(beandeserializer.java:289) @ com.fasterxml.jackson.databind.deser.beandeserializer._deserializeother(beandeserializer.java:157) @ com.fasterxml.jackson.databind.deser.beandeserializer.deserialize(beandeserializer.java:123) @ com.fasterxml.jackson.databind.deser.std.collectiondeserializer.deserialize(collectiondeserializer.java:230) @ com.fasterxml.jackson.databind.deser.std.collectiondeserializer.deserialize(collectiondeserializer.java:207) @ com.fasterxml.jackson.databind.deser.std.collectiondeserializer.deserialize(collectiondeserializer.java:23) @ com.fasterxml.jackson.databind.objectmapper._readmapandclose(objectmapper.java:2888) @ com.fasterxml.jackson.databind.objectmapper.readvalue(objectmapper.java:2034)
i used xmlmapper directly,
xmlmapper.readvalue(responsexml, transactionobjectlistresponse.class);
response entity structure isn't strict, appricated. thanks.
i had similar issue running 2.2 version of "jackson-dataformat-xml". took 1 library down version , worked.
ie. (if using maven)
<dependency> <groupid>com.fasterxml.jackson.dataformat</groupid> <artifactid>jackson-dataformat-xml</artifactid> <version>2.2.3</version> </dependency>
this same version 3rd party java recurly library uses - http://search.maven.org/#artifactdetails%7ccom.ning.billing%7crecurly-java-library%7c0.1.6%7cjar
Comments
Post a Comment