Re: [jackson-user] Deserialize: nested xml document missing

107 views
Skip to first unread message

Tatu Saloranta

unread,
Nov 30, 2021, 3:20:55 PM11/30/21
to jackson-user
On Mon, Nov 29, 2021 at 4:05 PM Lakshmi Narayana Malempati <lmale...@gmail.com> wrote:
Hi there,
When de-serializing the attached xml, the nested xml doc under the 'payload'
element comes blank. my code:

Background:
We have a java application that serializes java objects that are created
from XSD file using the JAXB library. Since jaxb does not support android,
we have started using jackson as this library will be consumed by android
app.

XmlMapper mapper = (XmlMapper) new
XmlMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,
false);

  ^^^^ Please PLEASE do not disable this until it is really needed -- this is what prevents
you from seeing the problem there is.

It is by far the most common issue with testing from what I have seen: users assume they
want this. But during development they typically do not.
 
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true);
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_VALUES, true);
Response response1 = null;
try {
    response1 = (Response) mapper.readValue(xml, Response.class);
} catch (IOException e) {
    e.printStackTrace();
}
I am new to java and jackson, Could you help me get past this?

Try leaving FAIL_ON_UNKNOWN_PROPERTIES enabled first; that will likely show
you that the structure of `Response` is different than what is needed for XML payload.

-+ Tatu +-

 

Thanks.

--
You received this message because you are subscribed to the Google Groups "jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-user/7a570eb5-6a5a-43fc-bb26-422864e2880en%40googlegroups.com.

Lakshmi Narayana Malempati

unread,
Dec 2, 2021, 10:48:38 AM12/2/21
to jackson-user
Thank you for the response.
I have implemented your suggestions.

Reply all
Reply to author
Forward
0 new messages