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

polymorphic deserialization of JSON with jackson, property type becomes "null"

I am using Jackson to convert a big Json string into various classes and subclasses. I have a list of objects, each containing a node object, a last result object and a children array. The children array contains a list of objects with exactly the…
Wim Berchmans
  • 271
  • 2
  • 12
7
votes
1 answer

Polymorphic Jackson deserialization: getting either a string or an array of strings

My question is pretty much identical to this one, except that I'm using Java/Jackson instead of C#: In C# how can I deserialize this json when one field might be a string or an array of strings? My input JSON can be this: { "foo": "a string" } or…
ccleve
  • 15,239
  • 27
  • 91
  • 157
7
votes
1 answer

Jersey: How to Add Jackson to Servlet Holder

I am creating an embedded Jetty webapp with Jersey. I do not know how to add Jackson for automatic JSON serde here: ServletHolder jerseyServlet = context.addServlet( org.glassfish.jersey.servlet.ServletContainer.class, "/*"); …
David Williams
  • 8,388
  • 23
  • 83
  • 171
7
votes
1 answer

Upgrading Jackson in GlassFish 4.1

I am using GlassFish 4.1, which includes Jackson 2.3.2. I would like to upgrade to the newest version of Jackson (currently 2.4.4). Is the procedure for upgrading Jackson in GlassFish 4.1 as simple as: a) stopping GlassFish b) deleting the…
XDR
  • 4,070
  • 3
  • 30
  • 54
7
votes
1 answer

@JsonPropertyOrder not working with jackson-module-jsonSchema

I'm using the latest branch for Jackson module - jackson-module-jsonSchema i.e. 2.4.4-Snapshot. I'm trying to use the @JsonPropertyOrder annotation to maintain the order of the POJO attributes, but it seems to be not respecting the annotation. My…
Piyush Jajoo
  • 1,095
  • 2
  • 18
  • 27
7
votes
1 answer

@jsonview of jackson not working with jax-rs

I have written following code: class A{ public static class Public { } } // Entity class public class B{ @JsonView({A.Public.class}) int a; int b; } public class C{ @GET @Produces(MediaType.APPLICATION_JSON) …
Jayendra Gothi
  • 682
  • 2
  • 11
  • 26
7
votes
4 answers

Hibernate and JSON - is there a definitive solution to circular dependencies?

I'm struggling with Hibernate entities and JSON in these days and, although there is a lot of questions regarding the object, I'm yet not capable to serialize in presence of circular dependencies. I tried with both Gson and jackson but I didn't get…
tigerjack
  • 1,158
  • 3
  • 21
  • 39
7
votes
3 answers

How to include only specific properties when serializing with Jackson

I am trying to implement a universal method which serializes the given object to JSON, but only those properties which are passed in a collection. If possible I want to get this functionality without specifying @JsonFilter on the class. For this I…
Daniel Szalay
  • 4,041
  • 12
  • 57
  • 103
7
votes
1 answer

Jackson JSON Parser performance

Multiple posts on the Internet point toward Jackson as having better parsing performance than GSON, granting somewhere in the neighborhood of 20-30% speed improvement.…
markshiz
  • 2,501
  • 22
  • 28
7
votes
2 answers

Output list of all paths to leaf nodes in a json document in java

For example: Given this json document: { "store": { "book": [ { "category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price":…
L. Blanc
  • 2,150
  • 2
  • 21
  • 31
7
votes
3 answers

Scala Jackson object mapper setting null instead of default values in case class

have a case class Person with default param. pass mapper a string missing a param, mapper sets it as null. expecting it to set the default value why is this ? example : @JsonIgnoreProperties(ignoreUnknown = true) case class…
Nimrod007
  • 9,825
  • 8
  • 48
  • 71
7
votes
1 answer

How to let Jackson deserialize nested objects in custom deserializer

In my project I have some JsonDeserializers to deserialize abstract types in collections. Now I have a type which has a Collection property. How can I instruct Jackson to deserialize the nested collection for me instead of doing it myself? interface…
Bart
  • 17,070
  • 5
  • 61
  • 80
7
votes
4 answers

Possible to configure Jackson-Json Mapper to exclude properties based on which object it is serializing?

Say I have objects such as a Business with a List of Address objects, and an Order that has a Business. Is it possible to configure so that when the Order is serialized it excludes the list of addresses from the Business object, and when the…
Robby Pond
  • 73,164
  • 16
  • 126
  • 119
7
votes
1 answer

dynamic json response: Could not read JSON: N/A (through reference chain) jackson fasterxml

I want to access a REST api with a variable amount of product codes as parameters. The JSON response will give me a token for every code I submit. The problem is the root elements of the json response will be the product codes I submitted, so I…
Sven Deckers
  • 155
  • 1
  • 1
  • 9
7
votes
4 answers

Jackson JsonMappingException: Can not deserialize instance

I'm trying to convert my json data to a POJO object using Jackson. Here is the MainActivity and my POJO class code. I'm basically getting a JsonMappingException error. I have also attached the whole log. MainActivity.java : ObjectMapper mapper = new…
Azhar92
  • 923
  • 2
  • 8
  • 17