Unable to deserialize root-level `Instant` value from XML
See original GitHub issueUnable to deserialise XML to Instant value
Jackson version: 2.10.1 Java version: Java 8
Code to reproduce:
XmlMapper mapper = new XmlMapper();
mapper.registerModule(new JavaTimeModule());
String instant = mapper.writeValueAsString(Instant.now());
Instant instantOutput = mapper.readValue(instant, Instant.class);
Stack trace:
Exception in thread "main" com.fasterxml.jackson.databind.exc.MismatchedInputException: Unexpected token (START_OBJECT), expected one of [VALUE_STRING, VALUE_NUMBER_INT, VALUE_NUMBER_FLOAT] for java.time.Instant value
at [Source: (StringReader); line: 1, column: 1]
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1442)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1216)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1148)
at com.fasterxml.jackson.datatype.jsr310.deser.JSR310DeserializerBase._handleUnexpectedToken(JSR310DeserializerBase.java:105)
at com.fasterxml.jackson.datatype.jsr310.deser.JSR310DeserializerBase._handleUnexpectedToken(JSR310DeserializerBase.java:118)
at com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer.deserialize(InstantDeserializer.java:231)
at com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer.deserialize(InstantDeserializer.java:50)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4202)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3205)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3173)
at uk.co.argos.availability.server.Temp.main(Temp.java:19)
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Unable to deserialize from xml file - Stack Overflow
I have created a class for the data to be extracted from the xml file. But when deserialixing back to object I am...
Read more >Converting JSON to XML and XML to JSON in a Flow | Power ...
In this very simple post, let's look at how you can convert JSON to XML and XML back to JSON while working in...
Read more >Jackson - Quick Guide - Tutorialspoint
Jackson is a simple java based library to serialize java objects to JSON and vice ... Method called to locate deserializer for the...
Read more >ERROR:"Failed to import the XML file Reason ... - Search
Reason: [[IO_0009] Failed to deserialize XML, Detailed message: '[IO_1026] Deserialization failed. Unknown element 'importParams' found during ...
Read more >Trying to create a Component with the Core Service: Data at ...
public static string Serialize<T>(T value) { if (value == null) { return null; } ... Serialize(xmlWriter, value); } return textWriter.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I changed my mind. Since I have been able to, I think, to support this for basic JDK scalar values, I think same might be possible for date/time types as well. Not 100% certain yet but hope to test the idea soon.
Awesome!