Git Product home page Git Product logo

Comments (9)

cowtowncoder avatar cowtowncoder commented on September 1, 2024

Adding unit test: can reproduce the problem as described... will try to see what gives the problem.

from jackson-dataformat-xml.

cowtowncoder avatar cowtowncoder commented on September 1, 2024

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.

cowtowncoder avatar cowtowncoder commented on September 1, 2024

Managed to fix by checking and using wrapper name for deserialization, instead of property name.

from jackson-dataformat-xml.

cowtowncoder avatar cowtowncoder commented on September 1, 2024

Strange. Things work ok when annotations are added on setters, but not when added on getters...

from jackson-dataformat-xml.

cowtowncoder avatar cowtowncoder commented on September 1, 2024

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.

fredcooke avatar fredcooke commented on September 1, 2024

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.

fredcooke avatar fredcooke commented on September 1, 2024

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.

cowtowncoder avatar cowtowncoder commented on September 1, 2024

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.

cowtowncoder avatar cowtowncoder commented on September 1, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.