[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 ObjectMapper()..configure(DeserializationFeatur

[jackson-user] java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ObjectMapper in Java 11

2018-12-04 Thread Dvir L
We are using Jackson 2.8.5.tr1 (jackson-databind, jackson-core, jackson-annotations) within our jar file and it works fine using Java 8. When trying to run our jar file using Java 11, we are getting a runtime exception - Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.data

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 fo

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. : {"a":"

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 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 you

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 Tue

[jackson-user] Re: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ObjectMapper in Java 11

2018-12-04 Thread oxyg3n8
The latest Jackson version is 2.9.7, I was also told that 2.9.8 will have some JDK 9+ compatibility work done on it. I would say; try 2.9.7 and see if you don't get that error, here is the link to the JDK 9+ comment: https://github.com/FasterXML/jackson-dataformats-binary/issues/153#issuecomment