I want to serialize and deserialize objects like java Date
or UUID
to and from String.
The problem is that it surrounds the String itself with double quotes:
String s = objectMapper.writeValueAsString(date);
System.out.println("String: @@" + s + "@@"); // String: @@"2017-12-06T04:50:30Z"@@
...
Date d = objectMapper.readValue(s, Date.class); // Expects the String to be "\"2017-12-06T04:50:30Z\""
Is there a way to configure the object mapper to not use/expect the redundant double quotes?
If anyone faces the same problem: I didn't find any other way but an ugly workaround. I just remove/add the quotes to the string after/before passing it to the object mapper.