Comments (9)
Adding unit test: can reproduce the problem as described... will try to see what gives the problem.
from jackson-dataformat-xml.
Looks like there is discrepancy between expected regular name, wrapper name (for test, changing local name to be 'notes' makes test pass for example).
from jackson-dataformat-xml.
Managed to fix by checking and using wrapper name for deserialization, instead of property name.
from jackson-dataformat-xml.
Strange. Things work ok when annotations are added on setters, but not when added on getters...
from jackson-dataformat-xml.
Ok: needed to add quite a bit more code, workarounds than anticipated, but things now work.
New code should be more robust as well. Please let me know if I still managed to miss something...
from jackson-dataformat-xml.
I appear to still be getting this, or something similar, in 2.1.3. I've got annotations setup to correctly create this:
<Root BuildVersion="1.1.1" Description="horribleformatthati'mstuckwith" DataInterchangeType="dit" Locale="local pub">
<Batch name="botched">
<Documents>
<Document DocID="hg is better" DocType="rocksml" MimeType="daddytype">
<Tags>
<Tag id="hello" TagName="icknd" TagDataType="pasta">of no value at all</Tag>
<Tag id="hello2" TagName="icknd2" TagDataType="pasta2">of no value at all2</Tag>
</Tags>
</Document>
<Document DocID="git is better" DocType="sucksml" MimeType="mummytype">
<Tags>
<Tag id="hell3o" TagName="ick3nd" TagDataType="p3asta">of no v3alue at all</Tag>
<Tag id="hello42" TagName="icknd42" TagDataType="pas4ta2">of no value at al4l2</Tag>
</Tags>
</Document>
</Documents>
</Batch>
</Root>
However it can not read it back in, giving the following slightly sanitised error:
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "Documents" (class com.example.bcn.tara.xml.perceptive.Batch), not marked as ignorable (2 known properties: , "name", "Document"])
at [Source: java.io.FileInputStream@243f01d4; line: 1, column: 221] (through reference chain: com.example.bcn.tara.xml.Perceptive["Batch"]->com.example.bcn.tara.xml.perceptive.Batch["Documents"])
at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:79)
at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:579)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:672)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:906)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:328)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:121)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:375)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:98)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:308)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:121)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2797)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:1989)
at com.example.bcn.tara.XMLMain.main(XMLMain.java:85)
... 6 more
The relevant lines from the Batch object:
@JacksonXmlProperty(isAttribute=true)
private String name;
@JacksonXmlElementWrapper(localName="Documents")
@JacksonXmlProperty(localName="Document")
private List<Document> documents;
Let me know if I can help in any way. I'm happy to try snapshots if you deploy them to sonatype's OSS repo.
from jackson-dataformat-xml.
FYI, I could, of course, serialise and deserialise in both JSON and YAML using 2.1.3. In the end having heard nothing back from you guys, I tried simple 2.6.9, and found it to not be simple at all. Then I tried XStream and it works superbly. I'm still interested in seeing this resolved, though, as I would REALLY like to use Jackson as my catch-all serialiser/deserialiser across all of XML, JSON, YAML in a single application.
from jackson-dataformat-xml.
Sorry for slow response here. There are issues with List (de)serialization, and I hope they all come from a single root cause, to be fixed for Jackson 2.2.
from jackson-dataformat-xml.
After fixing other issues (#47, #55), I think this may well have been fixed: if anyone thinks there are leftovers from this one, please file a new issue.
from jackson-dataformat-xml.
Related Issues (20)
- Java bean serialization XML encoding problem HOT 1
- Without setting `@JsonCreator` for the POJO, the `required` attribute in `@JsonProperty` is not checked HOT 1
- Disabling wrapper on list (e.g. defaultUseWrapper = false) does not serialize/deserialize null lists as expected HOT 2
- When the `localName` property of `@JacksonXmlProperty` is not set, the `required` of `@JsonProperty` does not detect the property name of POJO HOT 10
- java.lang.IllegalArgumentException: Cannot deserialize value of type `java.util.ArrayList<RetInfArryDTO> from Object value (token `JsonToken.START_OBJECT`) HOT 8
- Add `XmlMapper.createGenerator(XMLStreamWriter)` and `XmlMapper.createParser(XMLStreamReader)` overloads
- Support use of xsi:type for polymorphic deserialization (FromXmlParser.Feature.AUTO_DETECT_XSI_TYPE)
- Support Encoding option when writing XML HOT 1
- `JacksonXmlAnnotationIntrospector.findNamespace()` should properly merge namespace information
- xmlMapper.readValue( xmlString , Bean.class ) for Single Boolean Value does not get the value defaults with false HOT 1
- XML serialization of floating-point infinity is incompatible with JAXB and XML Schema HOT 2
- native compilation error with version 2.17.0 of com.fasterxml.jackson.dataformat:jackson-dataformat-xml HOT 3
- Deserializing fails when using builder classes with `Iterable` Collection setters HOT 11
- Deserialization into collection does not respect namespaces HOT 4
- Cannot construct instance of `PEPSchema.MEMBER` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('Yes1') HOT 8
- Conflicting Getter Definitions for Different List Properties with Same Element as Content (dup of #27) HOT 4
- Nesting depth in `XmlReadContext` is not incremented/decremented on JsonToken.START_OBJECT/JsonToken.END_OBJECT HOT 5
- Class attribute annotation with "@" stopped working in 2.17.+, parsing says "name expected" HOT 4
- @JacksonXmlProperty appears to behave differently than @JsonProperty when used on java records HOT 1
- How to avoid wstxns1: prefix HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jackson-dataformat-xml.