Re: [jackson-user] Deserialize JSON string to Map

2018-12-05 Thread Tatu Saloranta
On Tue, Dec 4, 2018 at 1:01 PM wrote: > > You can also deserialize as JsonNode: > > JsonNode json = new ObjectMapper.readValue(jsonString, JsonNode.class); > > That will take care of the Json array, you can iterate property by property > and ask if isJsonArray() or something like that. > You can

Re: [jackson-user] Deserialize JSON string to Map

2018-12-04 Thread oxyg3n8
See the following Java Docs: - *JsonNode:* https://fasterxml.github.io/jackson-databind/javadoc/2.9/com/fasterxml/jackson/databind/JsonNode.html - *TreeNode which is the superclass of JsonNode:* http://fasterxml.github.io/jackson-core/javadoc/2.9/com/fasterxml/jackson/core/TreeNode.html On

Re: [jackson-user] Deserialize JSON string to Map

2018-12-04 Thread oxyg3n8
You can also deserialize as JsonNode: JsonNode json = new ObjectMapper.readValue(jsonString, JsonNode.class); That will take care of the Json array, you can iterate property by property and ask if *isJsonArray()* or something like that. You can also read each value *asText()* which will give

Re: [jackson-user] Deserialize JSON string to Map

2018-12-04 Thread Tatu Saloranta
On Tue, Dec 4, 2018 at 12:27 PM Pankaj Dighe wrote: > Thanks for the response. Using TypeReference>() { } > works fine when I have following json > > String jsonString = "{\"personId\": 231, \"percentage\": 2.1212, \"name\": > \"Name\", " + > "\"activeDate\":\"26-09-2017 11:00:00\"}"; >

Re: [jackson-user] Deserialize JSON string to Map

2018-12-04 Thread Pankaj Dighe
Thanks for the response. Using TypeReference>() { } works fine when I have following json String jsonString = "{\"personId\": 231, \"percentage\": 2.1212, \"name\": \"Name\", " + "\"activeDate\":\"26-09-2017 11:00:00\"}"; but does not work when I have nested json objects. E.g. :

Re: [jackson-user] Deserialize JSON string to Map

2018-12-04 Thread Tatu Saloranta
On Tue, Dec 4, 2018 at 10:45 AM Pankaj Dighe wrote: > I am trying to deserialize following JSON to map of > > String jsonString = "{\"personId\": 231, \"percentage\": 2.1212, \"name\": > \"Name\", " + > "\"activeDate\":\"26-09-2017 11:00:00\"}"; > > > I am trying to deserialize using

[jackson-user] Deserialize JSON string to Map

2018-12-04 Thread Pankaj Dighe
I am trying to deserialize following JSON to map of String jsonString = "{\"personId\": 231, \"percentage\": 2.1212, \"name\": \"Name\", " + "\"activeDate\":\"26-09-2017 11:00:00\"}"; I am trying to deserialize using following code: new