LocalDateTime double quotation on (de)serialization
See original GitHub issuejackson 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:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top 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 >
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 Free
Top 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
my bad - sorry! found my error!
Yeah I don’t really see a problem here. JSON String values must be quoted, and test as included passes as expected.