FAQ Database Discussion Community


Jackson - Extract Data without Brackets, Commas, and =?

java,json,object,jackson,jackson-modules
I don't know a ton about Jackson, I'm just using it because I needed to share data from Python to Java. Anyway my code is pretty simple ObjectMapper mapper = new ObjectMapper(); Map<String,Object> data = mapper.readValue(new File(FileName), Map.class); System.out.println(data.get("SomeInput")); This is what I'm getting: {Y=0.830168776371308, Z=0.16877637130801687, X=0.0010548523206751054} I really just...

Reading skipped children in Jackson Custom Deserializer

java,json,jackson,deserialization,jackson-modules
I have a deserializer for a specific class which needs some ordering while reading fields. Let's say I have two fields in my class (field1 and field2) and in order to read field2, it first needs field1. For example for the following json data it works because when the deserializer...

Serialization and Deserialization of JodaTime dates as json

java,json,jackson,jodatime,jackson-modules
According to the documentation found here https://github.com/FasterXML/jackson-datatype-joda the following code snippet should pass ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JodaModule()); final String INPUT_JSON = "{\"start\" : \"1972-12-28T12:00:01.000Z\"}"; Bean bean = mapper.readValue(INPUT_JSON, Bean.class); String json = mapper.writeValueAsString(bean); Assert.assertEquals(INPUT_JSON, json); However, this instead returns: org.junit.ComparisonFailure: Expected :{"start" : "1972-12-28T12:00:01.000Z"} Actual...

Migrating from Jackson-Module-Scala 2.4 to 2.5

json,scala,serialization,jackson,jackson-modules
I'm using jackson-module-scala 2.4 successfully with the wrapper below to serialize and deserialize various complex objects. When changing to jackson-module-scala 2.5 many deserializations (JSON to object) fail. For instance, the deserialization of the following simple list fails. val myList = MyListClass(List(1,2,3,4)) val myListJson = "{\n \"myList\" : [ 1, 2,...