I would like to read an XML stream with readValues, but if I wish to do something like:
mapper.readValues("<Content><a>i1</a><b>1</b></Content><Content><a>i2</a><b>2</b></Content><Content><a>i3</a><b>3</b></Content>")
Find a concrete example in
Then I get the error:
com.fasterxml.jackson.databind.exc.MismatchedInputException:
Cannot construct instance of `bet.algotech.persistence.file.Content`
(although at least one Creator exists):
no String-argument
constructor/factory method to deserialize from String value ('i1')
Note that instead if I provide
mapper.readValues("<Anything><Content><a>i1</a><b>1</b></Content><Content><a>i2</a><b>2</b></Content><Content><a>i3</a><b>3</b></Content></Anything>")
then everything works.
<Anything> can be whatever - Jackson just needs a start and end tag which does not need to have a corresponding POJO defined in the code.
¶ My question is: Is there a straightforward way to make Jackson work under the assumption that the XML stream contains a sequence of objects of the same type,
-- similarly as it currently happens for the Json case """{"a":"i1", "b":1}{"a":"i2", "b":2}{"a":"i3", "b":2}""" (where no explicit array is given) --
so that this use case does not fail?