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.

LocalDateTime double quotation on (de)serialization

See original GitHub issue

jackson v2.10.0

LocalDateTime values get wrapped in additional " quotes on serialization and fail deserialization if not quoted (e.g. "\"2014-12-20T02:30:10\"").

  @Test
  void serializingJava8Date() throws Exception {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JavaTimeModule());
    mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    LocalDateTime date = LocalDateTime.of(2014, 12, 20, 2, 30, 10);
    String result = mapper.writeValueAsString(date);
    assertEquals(result, "\"2014-12-20T02:30:10\"");
    LocalDateTime date2 = mapper.readerFor(LocalDateTime.class).readValue("\"2014-12-20T02:30:10\"");
    assertEquals(date, date2);
  }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
osahnercommented, Oct 22, 2019

my bad - sorry! found my error!

0reactions
cowtowncodercommented, Oct 22, 2019

Yeah I don’t really see a problem here. JSON String values must be quoted, and test as included passes as expected.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Serialize Java8 LocalDateTime to UTC Timestamp using ...
The following solution solves the task of serialize/deserialise the LocalDateTime to the timestamp and relevant at least for spring-boot ...
Read more >
JSON parse error: Cannot deserialize value of type `java.time ...
... Java Jackson Deserialization error: JSON parse error: Cannot ... LocalDateTime ` This is the JsonFormat pattern that you will most likely ...
Read more >
cannot deserialize value of type `java.time.localdatetime` from ...
In this video, we go through solving this rather annoying Java Jackson Deserialization error: JSON parse error: Cannot deserialize value of type `java.time.L......
Read more >
WildFly 15: Deserialize / serialize LocalDateTime as number
And that method escapes the String with double quotes. Seems it is not an easy task which can't be done just be changing...
Read more >
Jackson Exceptions - Problems and Solutions - Baeldung
This exception is thrown if the JSON String to be deserialized contains single quotes instead of double quotes.
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