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

Jackson to deserialize Map variable as empty Map instead of null

I'm using Jackson to deserialize a JSON that could contain null values for Map variables. What I want is if the value is null, I want the map to be an empty HashMap instead of null. JSON: {"names":null, "descriptions":null,…
Glide
  • 20,235
  • 26
  • 86
  • 135
7
votes
4 answers

Using Jackson, how can a list of known JSON properties be obtained for any arbitrary pojo class?

Ideally, it would look much like this: List props = objectMapper.getKnownProperties(MyPojo.class); Alas, there is no such method. An approach that would generally work is to explicitly set Include.ALWAYS as the ObjectMapper's default,…
Shaun
  • 2,490
  • 6
  • 30
  • 39
7
votes
3 answers

Hibernate Validator and Jackson: Using the @JsonProperty value as the ConstraintViolation PropertyPath?

Say I have a simple POJO like below annotated with Jackson 2.1 and Hibernate Validator 4.3.1 annotations: final public class Person { @JsonProperty("nm") @NotNull final public String name; public Person(String name) { this.name =…
Philip Lombardi
  • 1,276
  • 2
  • 17
  • 26
7
votes
5 answers

How do I parse JSON into a Map with lowercase keys using Jackson?

I am using the Jackson (1.9.x) library to parse JSON into a Map: ObjectMapper mapper = new ObjectMapper(); Map map = (Map) mapper.readValue(jsonStr, Map.class); Is there a way to tell the Jackson parser to lowercase…
quux00
  • 13,679
  • 10
  • 57
  • 69
7
votes
2 answers

How to use Apache Avro to serialize the JSON document and then write it into Cassandra?

I have been reading a lot about Apache Avro these days and I am more inclined towards using it instead of using JSON. Currently, what we are doing is, we are serializing the JSON document using Jackson and then writing that serialize JSON document…
user2467545
7
votes
1 answer

Jackson can't deserialize to a ForeignCollection (Ormlite)

I've have issues deserializing nested json data. I am using Ormlite to persist the data and a combination of Spring/Jackson(2) to fetch the data. Collections/lists of objects must be of the ForeignCollection interface before Ormlite will persist it.…
tougher
  • 499
  • 1
  • 3
  • 13
7
votes
2 answers

How to ignore a specific property when deserializing a JSON object?

I am working against a existing REST interface. One of the incoming JSON objects contains a property called size which I would like to ignore when deserializing this JSON object? My standard behavior is to fail on unknown property, so I cannot…
Oliver
  • 3,815
  • 8
  • 35
  • 63
7
votes
2 answers

Parsing issue when decoding a JSON String to generate the objects in java

Scenario : I am using following code to decode a JSON String to generate the objects using it. {"av":{"tid":"1000","sslist":[{"ss":{"ssId":"1","ssName":"Test ss "name one"}},{"ss":{"ssId":"2","ssName":"Test ss name two"}}],"hl":{"lc":0}}} Now, I…
ironwood
  • 8,936
  • 15
  • 65
  • 114
7
votes
1 answer

Inheriting @JsonCreator annotations from Superclass

I have a number of objects with a set of shared properties in a superclass: public Superclass { int id; String name; ... } And I have subclasses which inherit from the superclass but each of them need their own fully-described…
user1596371
7
votes
2 answers

Jackson: Override primitive type deserialization?

We need to process some broken JSON from a legacy server here that wrongly encodes null values as literal "null" strings in its output. I already found that I probably want to override…
Thomas Keller
  • 5,933
  • 6
  • 48
  • 80
7
votes
1 answer

Converting JSON array to POJO using jackson object mapper

This is possibly a duplicate question.. please refer this link. I am able to map one json object to POJO.But how can i convert array of json object to pojo using the same jackson framework. private void jsonToPojo(){ ObjectMapper mapper=new…
amalBit
  • 12,041
  • 6
  • 77
  • 94
7
votes
4 answers

JacksonParser databind and core cause "Found duplicate file for APK"?

I'm trying to learn how to use jackson parser, to get more effective parsing on json data. I have these jar files: Downloaded from this page jackson-core-2.2.0.jar jackson-annotations-2.2.0.jar jackson-databind-2.2.0.jar And in code, i just try…
yahya
  • 4,810
  • 3
  • 41
  • 58
7
votes
1 answer

How do I specialize deserializing 'null' with Jackson?

I have a class that can output any of the following: { title: "my claim" } { title: "my claim", judgment: null } { title: "my claim", judgment: "STANDING" } (notice how judgment is different in each case: it can be undefined, null, or a value) The…
Verdagon
  • 2,456
  • 3
  • 22
  • 36
7
votes
4 answers

Upgrading to Jackson 2.0 from 1.9 in Jersey not working

I'm using Jackson (in Jersey) to serialize entities, and I'm migrating from Jackson 1.9 to 2.0. I followed this guide, and at first it seemed like everything worked out easily. But a closer look reveals that Jackson 1.9 is still being used to…
Eyal
  • 3,412
  • 1
  • 44
  • 60
7
votes
1 answer

Have jackson ignore fields that are lazy initialized when serializing to json

I use Spring and am creating a REST service. Here's a part of my controller: @RequestMapping("/get") public @ResponseBody Person getPerson() { Person person = personRepository.findOne(1L); //(1) person.setRoles(null); return…
Matsemann
  • 21,083
  • 19
  • 56
  • 89