Questions tagged [jackson]

Jackson is a Java library for handling tasks like reading and writing (parsing / generating) and data binding to/from Java objects. Although primarily used for JSON, Jackson also supports many other data formats such as Avro, CBOR, CSV, Java Properties, Protobuf, Smile, XML and YAML.

Jackson is a Java serialization and deserialization API typically used for reading and writing JSON, although other data formats such as Avro, CBOR, CSV, Java Properties, Protobuf, Smile, XML, and YAML are also supported. It offers multiple processing modes including "streaming", "data-binding" and "tree model"; of these, latter two builds on streaming processing.

The Jackson homepage is hosted on GitHub, and the project's Wiki is here.

Alternatives

Alternative Java-to-JSON binding solutions with similar APIs include FastJSON, Google Gson, and svenson. Yet more Java-to-JSON libraries are listed at json.org.

Performance

The latest performance benchmarks for these and other JSON serialization and deserialization solutions for Java are available online.

16401 questions
6
votes
3 answers

Configuring Jackson mixin in Spring Boot application

I created a mixin for my class. The mixin itself works fine, it's not the issue that most people have where they mix faterxml/codehaus annotations. I tested it in a unit test, creating the ObjectMapper "by hand" while using the addMixIn method - it…
dkaras
  • 195
  • 2
  • 12
6
votes
1 answer

StackOverflowError Jackson with Spring

I have a Spring Boot Project with Jackson. Whenever I start it, I get this exception (production environment only). SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in…
Dipanshu Verma
  • 459
  • 3
  • 8
  • 22
6
votes
1 answer

Java/Jackson - how does TypeReference() actually work?

I'm parsing JSON strings sent from my WLAN speakers using Java/Jackson, whose format is unfortunately varying. While there's some static and not so important part of the response which is quite easy to parse, the really essential stuff may have many…
6
votes
1 answer

How set jackson for ignore a boolean property when it false?

I use Jackson, ObjectMapper.readValue(json, Class). Have a class: Component { private String name; private String someField; private boolean show = true; // if false -> skip it object } and extensible class: ExtendedComponent extends…
6
votes
4 answers

Jackson deserialize based on property name

I have the following two types of JSON objects: {"foo": "String value"} and {"bar": "String value"} Both of them represent a specialized type of the same base object. How can I use Jackson for deserializing them ? The type information is only…
user1925405
  • 332
  • 1
  • 5
  • 13
6
votes
2 answers

Jackson XML Deserialisation Issue

I am able to write a XML document, however am unable to deserialise the XML which is created. Original code is in Kotlin, however I've posted the Java equivalent. @JacksonXmlRootElement(localName = "assets") public class Assets { …
6
votes
2 answers

Error converting JSON string to map in Java using Jackson

I have this little piece of code, and I'm trying to convert a JSON string to a map. String json = "[{'code':':)','img':''}]"; ObjectMapper mapper = new ObjectMapper(); Map userData =…
Laphroaig
  • 619
  • 4
  • 12
  • 26
6
votes
1 answer

How to customly serialize or convert a Map property with custom key type in Jackson JSON (de-)serialization?

I'm serializing instances of @JsonIdentityInfo( generator = ObjectIdGenerators.PropertyGenerator.class, property = "id", scope=Entity1.class) public class Entity1 { private Long id; @JsonSerialize(converter =…
Kalle Richter
  • 8,008
  • 26
  • 77
  • 177
6
votes
2 answers

Should I use a wrapper or primitive type as field while using Jackson

I'm using Jackson JSON parser. I have simple data transfer object which should be returned via REST service. public class PersonDto { private String name; private Integer age; // int? public PersonDto(String name, Integer age) { …
k13i
  • 4,011
  • 3
  • 35
  • 63
6
votes
3 answers

Ignoring null fields when deserializing with Jackson

I have the following Kotlin data class: data class TestObject( val boolField: Boolean, val stringField: String, val nullBoolField: Boolean = true, val nullStringField: String = "default", val…
George
  • 497
  • 6
  • 11
6
votes
1 answer

Make Jackson deserialize into private fields without setter or constructor

I managed to configure Jackson to serialize a class without any getters or annotations on the private fields inside the class by just using objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); But I don't manage to…
GreenTurtle
  • 1,144
  • 2
  • 21
  • 35
6
votes
1 answer

How to detect missing field when converting jsonObject to Model Object

I am sending a JsonObject using web service. The method that receives the call has a method parameter of model Object for the corresponding JsonObject Input being passed. The JsonObject is successfully getting converted to model object but I am…
Tarun
  • 271
  • 1
  • 6
  • 18
6
votes
2 answers

How to set jackson serialization depth level when using ObjectMapper?

Assuem that i have this below classes: public class Employee { private Department department; // other fields, getters and setters omited for brevtity } public class Department { private Address address; // other fields, getters…
Rasool Ghafari
  • 4,128
  • 7
  • 44
  • 71
6
votes
2 answers

How do I force Jackson to use an Object's Setters?

Given I have the following JSON file: { "cleanup": false, "clearCache": false } and the following bean: import org.apache.commons.lang3.Validate; import com.fasterxml.jackson.annotation.JsonProperty; public class Config implements…
liltitus27
  • 1,670
  • 5
  • 29
  • 46
6
votes
2 answers

Parsing Yaml in Java

I have the following YAML I want to parse using Jackson parser in Java. android: "7.0": - nexus - S8 "6.0": - s7 - g5 ios: "10.0": - iphone 7 - iphone 8 I created a created class which has…
Damien-Amen
  • 7,232
  • 12
  • 46
  • 75
1 2 3
99
100