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.

Unable to deserialize root-level `Instant` value from XML

See original GitHub issue

Unable 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:closed
  • Created 4 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
cowtowncodercommented, Jun 30, 2020

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.

0reactions
afayescommented, Jun 30, 2020

Awesome!

Read more comments on GitHub >

github_iconTop 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 >

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