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
8
votes
1 answer

How to map OneToOne relationship between POJOs using @JsonManagedReference and @JsonBackReference

I have read http://vard-lokkur.blogspot.com/2010/10/json-jackson-to-rescue.html http://vard-lokkur.blogspot.com/2010/10/json-jackson-serialization-narrowed.html http://www.cowtowncoder.com/blog/archives/2010/09/entry_418.html looking for…
Steinway Wu
  • 1,288
  • 1
  • 12
  • 18
8
votes
1 answer

Map a JSON field that can have different types with Jackson?

I get JSON from a web service and can not influence the JSON format. The JSON code below is just an example to illustrate the problem. The field cars can either be an object containing Car objects or it can be an empty string. If I could change the…
Adrian H.
  • 569
  • 6
  • 17
8
votes
1 answer

Spring APIs returning XML instead of JSON

I have two spring boot projects - A(Main larger project with APIs) and B(a library which is imported by A as a dependency in pom.xml) pom.xml of project B:
rsp
  • 813
  • 2
  • 14
  • 26
8
votes
2 answers

Kotlin and Jackson - Missing type id when trying to resolve subtype of simple type

I have a Kotlin sealed class - Pet and two subclasses - Dog and Cat. My application requires to transfer a collection of pets serialized in JSON. In order to differentiate subclasses I use Jackson @JsonTypeInfo and @JsonSubTypes annotations. The…
yanefedor
  • 2,132
  • 1
  • 21
  • 37
8
votes
5 answers

best approach for marshaling unmarshaling immutable objects with builder pattern

I have a simple restful service that I'm developing in java. I have been looking at a few of the options for marshalling/unmarshalling json. The possible approaches available, jaxb jackson etc, are quite new to me and I'm trying to find my feet with…
Conor
  • 775
  • 3
  • 10
  • 23
8
votes
3 answers

Jackson XML deserialization skips field when using multiple useWrapping = false

I am trying to deserialize the following XML: My Jackson classes are: @Data public class Foo { @JacksonXmlProperty(isAttribute = true) private String…
Michael
  • 41,989
  • 11
  • 82
  • 128
8
votes
2 answers

How to deserialize a string separated by comma to list with Jackson commonly?

I have a json like: { "names": "John, Tom", "values": "8, 9", "statuses": "yes, no" } and want to deserialize to: class Bean { private List names; private List values; private List statuses; } I know that…
Wong
  • 83
  • 1
  • 5
8
votes
0 answers

java.lang.NoSuchMethodError: com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper

I have a library X which has a dependency on jackson-module-scala version 2.9.7. It contains this object: import com.fasterxml.jackson.databind._ import com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper val Mapper = new…
Sarin Madarasmi
  • 526
  • 6
  • 11
8
votes
1 answer

Jackson module not registered after update to Spring Boot 2

I'm as upgrading from Spring Boot 1.5.21 to 2.2.5. I need to use MonetaryModule to deserialize rest calls, and depending on Spring's ObjectMapper. I have defined such a bean for this module in a some @Configuration class (MonetaryModule is extending…
8
votes
3 answers

Spring reactive WebClient GET json response with Content-Type "text/plain;charset=UTF-8"

I’m having an issue with Spring 5 reactive WebClient, when I request an endpoint that returns a correctly formated json response with content type "text/plain;charset=UTF-8". The exception…
Charlie
  • 311
  • 1
  • 3
  • 9
8
votes
0 answers

Make field insertable but not updatable in Spring Data REST + MongoDB

With Spring Data REST and Spring Data Mongo, I want to make a domain field (field username of domain User in my example) insertable when create but un-updatable when update. In other words an equivalent of JPA @Column(insertable = true, updatable =…
yejianfengblue
  • 2,089
  • 1
  • 14
  • 18
8
votes
2 answers

Jackson Databind ObjectMapper convertValue with custom mapping implementaion

Foo1 public class Foo1{ private Long id; private String code; private String name; private Boolean rState; private String comments; // Contain json data private String attachments; // Contain json data } Foo2 public class Foo2{ private…
Shahid Ghafoor
  • 2,991
  • 17
  • 68
  • 123
8
votes
1 answer

Create clone of jackson ObjectMapper Instance

I'm writing a library that needs a com.fasterxml.jackson.databind.ObjectMapper instance. The user of the library should be able to provide the configuration for the ObjectMapper or the ObjectMapper instance itself. But I also add/modify some…
Raman
  • 548
  • 1
  • 7
  • 17
8
votes
2 answers

Fastest way to parse JSON from String when format is known

I want to parse a String into an internal JSON object (or equivalent) in Java. The usual libraries, Gson and Jackson, are way too slow for my needs (> 100us for each String to Json parse, according to my benchmarks). I know there are slightly faster…
ABC
  • 693
  • 1
  • 10
  • 22
8
votes
1 answer

com.fasterxml.jackson.databind.exc.InvalidDefinitionException:Cannot construct instance of`java.time.Instant`(no Creators,like default construct):

I already went through link: JSON parse error: Can not construct instance of java.time.LocalDate: no String-argument constructor/factory method to deserialize from String value, but getting below…
PAA
  • 1
  • 46
  • 174
  • 282