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

Using Jackson 2.9.9 in java Spark

I am trying to use the MLLIB library (java) but one of my dependencies uses Jackson 2.9.9. I noticed that a pull request was made such that the master branch's dependency is upgraded to this particular version. Now I wanted to use this master branch…
Jasper
  • 628
  • 1
  • 9
  • 19
8
votes
4 answers

Enable Jackson Deserialization of Empty Objects to Null

I was asked to change our jackson mapping configuration so that each empty object we deserialize (from JSON) is going to be deserialized as null. The problem is that I'm struggling to do it, but without any luck. Here is a sample of our ObjectMapper…
Aladin
  • 492
  • 1
  • 8
  • 21
8
votes
4 answers

Slow first call after restarting Spring Boot application

We have a React - Spring Boot application using Postgres, Hibernate, Jackson and Spring Data Rest. After each application restart, the first call to a post route hitting one of our back-end servers is long (more than 4 seconds). Every subsequent…
Marc Janvier
  • 83
  • 1
  • 2
  • 10
8
votes
2 answers

Retrofit or Jackson ObjectMapper maps "aId" property to lowercase "aid"

I'm using Jackson 2.9.2 and Retrofit 2.1.0 for some POST operation with a JSONArray as HTML-Header parameter. The API defines a value which is aId. No matter what I try, my JSON property is always converted to lowercase (aid). I tested my same…
longi
  • 11,104
  • 10
  • 55
  • 89
8
votes
2 answers

How to instantiate beans in custom way with Jackson?

What is the best and easiest way to instantiate beans in custom way (not by calling default constructor) while deserializing from JSON using Jackson library? I found that there is JsonDeserializer interface that I could implement, but I'm not too…
Tomasz Błachowicz
  • 5,731
  • 9
  • 41
  • 47
8
votes
3 answers

Using Instant, LocalDateTime and ZonedDateTime with Spring Boot and ElasticSearch

I'm using Spring Boot 2.1.4 and Spring Data Jest with ElasticSearch. I was initially using Java Date for some properties with the following annotation: @JsonFormat(shape = JsonFormat.Shape.STRING, pattern ="yyyy-MM-dd'T'HH:mm:ss.SSSZZ") This is…
Swordfish
  • 1,127
  • 24
  • 46
8
votes
1 answer

@JsonFormat DEFAULT_TIMEZONE doesn't seem to be working

I am having some issue with date logic which I've isolated to Jackson, the JSON serializer. In the database and in a debug point in the application, dates are correct and everything is written using default timezone. However, in serialization 4…
8t12c7081
  • 683
  • 3
  • 9
  • 30
8
votes
2 answers

Jackson: Suppress JsonTypeinfo at serialisation time?

My supertype is annotated with @JsonTypeInfo(use = Id.NAME, include = As.PROPERTY, property = "_typeid") -so that serialised subtypes include the extra field _typeid containing the name of the subtype. This is intentional and necessary for my app.…
Joachim Lous
  • 1,316
  • 1
  • 14
  • 22
8
votes
1 answer

Serialization of key/value pairs in Jackson?

I have a class class Foo { String key; String value; } and want to serialize this into "":"" How can I achieve this (and how to deserialize "myKey":"myVal" into a Fooobject? I was trying to use…
Heiko Rupp
  • 30,426
  • 13
  • 82
  • 119
8
votes
1 answer

Java 8 Exception: com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer has no default (no arg) constructor

I have a model class that has a field: @JsonDeserialize(using = InstantDeserializer.class) @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ") private OffsetDateTime offsetDt; When a request of this model is sent to the server, my controller…
jlp
  • 1,656
  • 6
  • 33
  • 48
8
votes
2 answers

How to create default constructor for immutable class

I like to make my objects immutable based on this article (Why objects must be immutable). However, I am trying to parse an object using Jackson Object Mapper. I was initially getting JsonMappingException: No suitable constructor found for type…
SyncMaster
  • 9,754
  • 34
  • 94
  • 137
8
votes
6 answers

Sending protobuf as JSON in spring-boot

I´m using protobufs with this concrete definition. message Hash { string category = 1; repeated KVPair content = 2; } message KVPair { string key = 1; string value = 2; } I want to send this as JSON with my spring-boot…
8
votes
2 answers

Is it possible to make Jackson serialize a nested object as a string

Given these classes: @Value private static class Message { private final String type; private final MyType message; } @Value public class MyType { private final String foo; } Jackson will produce: { "Type" : "Test", "Message" :…
David
  • 7,652
  • 21
  • 60
  • 98
8
votes
1 answer

Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token

Below mentioned is the JSON string, resultString: { "imageMaps": [{ "crc": "c2c4", "flags": "0", "length": "117384", "index": 1, "version": "1.1.90ea", "status": "" }, { "crc": "7601", …
Random Coder
  • 329
  • 2
  • 5
  • 11
8
votes
1 answer

Is there a way to inject Jackson annotation values from a meta annotation, similar to Spring's AliasFor annotation?

We're using @JacksonAnnotationsInside and would like to inject a property from the classes using the meta annotation. i.e. we have a meta annotation with @JsonTypeInfo() and would like to inject the defaultImpl via the aggregating annotation. Here…
dev_feed
  • 689
  • 2
  • 7
  • 25