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

Unmarshal JSON to String, BigInteger and BigDecimal with jackson very close

We are using jackson, and I see this in the code DeserializationConfig.Feature.USE_BIG_DECIMAL_FOR_FLOATS DeserializationConfig.Feature.USE_BIG_INTEGER_FOR_INTS But how do I get jackson to use those features now? This would be the perfect…
Dean Hiller
  • 19,235
  • 25
  • 129
  • 212
7
votes
2 answers

Using Jackson JSON Parser: Complex JSON?

I have a complex JSON that I am trying to parse using Jackson JSON. I am a little confused about how to get into the latLng object to pull out the lat,lng values. This is part of the JSON: { "results": [ { "locations": [ …
Ronnie Dove
  • 107
  • 1
  • 3
  • 9
7
votes
2 answers

Spring Ajax - @ResponseBody - Returning null response

In my spring webapp, I have an ajax servlet that answer json (using jackson):
FF_Dev
  • 462
  • 5
  • 17
7
votes
3 answers

JSON4S unknown error

i am trying to get json4s to extract something but i get a "unknown error" My code looks like: import org.json4s._ import org.json4s.jackson.JsonMethods._ implicit val formats = org.json4s.DefaultFormats case class Person(name: String, age:…
Oliver Zachau
  • 71
  • 1
  • 2
7
votes
2 answers

Jackson - Wrapping a list of objects with root object

My Controller returns a list of MyObj objects (using @ResponseBody) public MyObj { int a; int b; } The return JSON looks like this: [{"a":1,"b":2},{"a":2,"b":2}] I would like to wrap this JSON so it will return something like: { "data":…
7
votes
1 answer

Jackson: @JsonTypeInfo missing in Arrays

I found some strange behavior of the Jackson JSON Processor library and i am curious whether this is intentional or a bug. Please have a look at the code below: @JsonTypeInfo(use = Id.NAME) public class Nut {} … ObjectMapper mapper = new…
nutlike
  • 4,835
  • 1
  • 25
  • 33
7
votes
4 answers

How to serialize transient fields using jackson?

We use JSON serialization with Jackson to expose internal state of the system for debugging properties. By default jackson does not serialize transient fields - but I wish to serialize them as well. How can I serialize these fields? One way I know…
Noam
  • 3,049
  • 10
  • 34
  • 52
7
votes
4 answers

Disable Jackson mapper for a particular annotation

With Jackson, it's easy to disable all annotations for a given ObjectMapper. Is there a way to only disable one given annotation? // disable all ObjectMapper mapper = new ObjectMapper() mapper.disable(MapperFeature.USE_ANNOTATIONS); // disable…
yves amsellem
  • 7,106
  • 5
  • 44
  • 68
7
votes
1 answer

Jackson: Serialization to JSON on Objects using nested Objects, merge child fields into owning class

Let's say I have Java classes that looks like this: public class A { public String name; public B b; } public class B { public int foo; public String bar; } I want to serialize an instance of A into JSON. I am going to use the…
ecbrodie
  • 11,246
  • 21
  • 71
  • 120
7
votes
2 answers

Deserializing a Generic Type with Jackson

I am trying to make a class that uses the Jackson to deserialize POJO's. It looks like this... public class DeserialiserImp implements Deserialiser { protected ObjectMapper objectMapper = new ObjectMapper(); @Override …
jiduvah
  • 5,108
  • 6
  • 39
  • 55
7
votes
3 answers

jaxb Unmarshaller : repeated xmlelement without wrapper

b1 b2 Since all the are not included in a…
James Yu
  • 153
  • 1
  • 4
7
votes
2 answers

How to do custom serialization/deserialization using JACKSON?

I am trying to convert the following gson serialization to JACKSON serialization. Please let me know what i need to change to make it work for JACKSON public class AbstractElementAdapter implements JsonSerializer,…
user1595858
  • 3,700
  • 15
  • 66
  • 109
7
votes
2 answers

deserialize lazy loading in hibernate and jackson

Is there a way to keep LAZY loading and deserialize the object using the id instead of the POJO object. I have 2 class that are joined by a many-to-many relationship. Something like this public class User { @Id @JsonProperty public long…
user1744206
  • 81
  • 1
  • 3
7
votes
1 answer

Java Jackson: Parsing a csv file into an object containing a List of objects

I am trying to parse a csv file using Jackson CsvParser into an object that also contains a list of another class. So the first 2 columns contain data that needs to be bound to the parent class and the data afterwards would need to be bound to…
DanF7
  • 171
  • 1
  • 2
  • 6
7
votes
2 answers

Parsing nested JSON

I have the following JSON: { "registration": { "name": "Vik Kumar", "first_name": "Vik", "last_name": "Kumar", "bloodGroup": "B-", "gender": "male", "birthday": "10\/31\/1983", "email": "vik.ceo\u0040gmail.com", …
Vik
  • 8,721
  • 27
  • 83
  • 168