question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

failed to deserialize all interleaved elements for list

See original GitHub issue

POJO:

@JacksonXmlRootElement(localName = "a")
public class A {
    public static class B {
        @JacksonXmlProperty(localName = "id")
        public String id;
    }

    @JacksonXmlProperty(localName = "b")
    @JacksonXmlElementWrapper(useWrapping = false)
    public List<B> bList;
}

XML:

<a>
   <b><id>id1</id></b>
   <any-tag/>
   <b><id>id2</id></b>
</a>

It’s expected to get two elements ‘id1’ and ‘id2’ in bList, but only ‘id2’ is available after deserialisation.

related links:

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
cowtowncodercommented, Mar 15, 2017

@pswulius one thing that 2.9 will add in jackson-databind is @JsonMerge like so:

public class Container {
   @JsonMerge(OptBoolean.TRUE)
   public List<Point> points = new ArrayList<>();
}

which would not reset value, so multiple segments would effectively be merged. I have not tried that with XML module but in theory it should work. Before 2.9 you could still add “setPoints(List<> p) { }” method that similarly appends entries, but that is bit more intrusive.

This assuming that problem is not due to mixed content (that is, no unwrapped text/cdata sections), but due to disjoint sequences of elements with same name.

0reactions
cowtowncodercommented, May 20, 2020

Since there is a work-around (or two) but no clear path on how to solve this in other ways, will close the issue: should be possible for users to find work-arounds on closed issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Serialize parallel arrays to XML in C# in a specific order
Xml Sequence deserialization with RestSharp shows how to use an [XmlAnyElement] property to generate an interleaved list of elements.
Read more >
Encoding Techniques in Verified Serializers - Ethan Shea
Before deserializing each element, it must be known that it actually is an element of the list, and not some other data coming...
Read more >
JSON Deserialize Error : Expected '[' at the beginning of List/Set
You are trying to serialize a single object json to List<SObject> . Convert your JSON back to its original form which is not...
Read more >
tf.data.Dataset | TensorFlow v2.11.0
Returns an iterator which converts all elements of the dataset to numpy. Use as_numpy_iterator to inspect the content of your dataset. To see...
Read more >
Encoding | Protocol Buffers - Google Developers
Encoding · A Simple Message · Base 128 Varints · Message Structure · More Value Types · Embedded Messages · Optional And Repeated...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found