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
7
votes
3 answers

Spring boot jackson non_null property not working

I am using Spring boot 1.5.7-RELEASE. I am trying to set global non null Jackson property in my application. but it is not working. I have tried both in application.properties and bootstrap.properties but not…
Ravat Tailor
  • 1,193
  • 3
  • 20
  • 44
7
votes
2 answers

OutOfMemoryError due to serialize Java Object to String using Jackson

I am using ObjectMapper from Jackson to convert the Java object to String in order to write it in my log file. The converting method looks like: private String getResponseAsString(OrderResponse response) { ObjectMapper mapper = new…
Bali
  • 705
  • 4
  • 13
  • 21
7
votes
1 answer

Jackson parsing exception -(although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value

Spring Boot Version : 1.5.10 Jackson Version : 2.9.5 Lombok Version : 1.18.0 I have a scenario where I am sending payload using kafka. On receiving that payload, I am trying to assert whether both payload at receiver and sender end are same or…
SUMIT
  • 540
  • 1
  • 4
  • 19
7
votes
2 answers

Unexpected character ('<' (code 60))

I'm getting a weird error. This used to work. I'm not sure if it is app server, code, jvm? JVM: Java Virtual Machine initialized. Java runtime version: pwa6480sr4fp5-20170421_01 (SR4 FP5) JVM version: JRE 1.8.0 Windows Server 2008 R2 amd64-64…
xpagesbeast
  • 776
  • 1
  • 10
  • 21
7
votes
4 answers

Generic object serialization in Jackson with Java

I would like to read in the string {"a": 1.0} as a generic Java Object while keeping the same string format. However, when I try, Jackson automatically changes the internal representation to {a = 1}. In other words, how can I get the following…
edd
  • 933
  • 2
  • 11
  • 24
7
votes
6 answers

How can I specify deserialization order in Jackson?

I have two fields: startDate and endDate and I need to make sure the end date is equal to or later than the start date. What's the best way to do this? I would like to ensure that endDate is deserialized after startDate, so I can put the logic in…
Don Rhummy
  • 24,730
  • 42
  • 175
  • 330
7
votes
1 answer

How can I register and use the jackson AfterburnerModule in Spring Boot?

I am using SpringBoot 1.5.9., Jackson 2.8 and Spring Framework 4.3.13. I am trying to register and use the AfterburnerModel. According to the Spring Boot documentation, to configure the ObjectMapper you can either define the bean yourself and…
dasPing
  • 337
  • 1
  • 2
  • 19
7
votes
2 answers

Jackson java.util.Date value in Map (de-)serialization

Consider this property @JsonProperty private Map myMap; When a contained java.util.Date value is serialized as long, it will not be deserialized to Date again because the type information is not present in Map. How…
Steffen Harbich
  • 2,639
  • 2
  • 37
  • 71
7
votes
3 answers

Jackson ignore getter from the class serializing

I'm trying to serialize a class on which I can't touch anything. The problem is I want to ignore some getWhatever() getter methods, but I can't mark the getter method with @JsonIgnore, as that would mean touching the DTO class. That serialization…
Pep Gomez
  • 197
  • 4
  • 14
7
votes
2 answers

Deserializing XML with list using Jackson

I have the following XML that I'd like to deserialize to Java POJO.
Damien-Amen
  • 7,232
  • 12
  • 46
  • 75
7
votes
1 answer

Specifying Jackson JSON subtypes on something other than the base class due to circular dependency

The basic issue that we are having is how to handle deserialization of JSON when there is a property that is typed as a base class that can be any one of several subclasses. There are many questions on this topic and the vast majority seem to point…
Todd Patch
  • 348
  • 1
  • 4
  • 15
7
votes
2 answers

Deserialize a SortedSet with a provided Comparator

Is it possible to deserialise a SortedSet or TreeSet (or SortedMap or TreeMap as a matter of fact) with a provided Comparator?
7
votes
1 answer

Jersey + Jackson deserialization failure with date object

I'm using jersey and jackson together to develop my REST API, and I'm having a problem when deserializing a date string. I have register a provider class in Jersey: @Provider public class MyJsonProvider extends JacksonJsonProvider { public…
fei
  • 2,224
  • 9
  • 31
  • 36
7
votes
2 answers

Why does Jackson's default deserializer set the Zone to UTC rather than Z?

I think I must be misunderstanding how Zones work in java's ZonedDateTime class. When I use Jackson to serialize and then deserialize now(), the deserialized value has getZone() == "UTC" instead of the "Z" in the serialized value. Can anyone…
Mark Wright
  • 705
  • 7
  • 20
7
votes
2 answers

Interfaces and @RequestBody

I'm currently working on a project which allows users to book (via the web) the use of a chosen resource for a given period of time. In this program I am trying to keep with Spring's philosophy (and the general best practice) of programming to…
Kristen D.
  • 268
  • 9
  • 20