Issue
Good day,
Please assist, I checked Jackson JsonNode but I can't seem to find what am looking for.
I need to know how to get JsonNode
as LocalDate
// Example : I can get int value like :
ObjectMapper mapper = new ObjectMapper();
final JsonNode data =mapper.readTree(json);
Int myNumberInt = data.get ("ngNumberInt").asInt();
How about LocalDate
, how do I get it from JsonNode
?
In my mind, am wishing there was
LocalDate dateCreated = data.get ("ngDate").asLocalDate();
Solution
JsonNode methods will only give you the JSON data types. However you can use your ObjectMapper instance to deserialize a LocalDate.
objectMapper.readValue(data, LocalDate.class)
You will need to include jackson-modules-java8
if you haven't already. This includes a serializer/deserializer for Java's LocalDate.
Answered By - Gorazd Rebolj
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.