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
1061
votes
10 answers

How to use Jackson to deserialise an array of objects

The Jackson data binding documentation indicates that Jackson supports deserialising "Arrays of all supported types" but I can't figure out the exact syntax for this. For a single object I would do this: //json input { "id" : "junk", …
Ollie Edwards
  • 14,042
  • 7
  • 28
  • 36
970
votes
51 answers

Jackson with JSON: Unrecognized field, not marked as ignorable

I need to convert a certain JSON string to a Java object. I am using Jackson for JSON handling. I have no control over the input JSON (I read from a web service). This is my input JSON: {"wrapper":[{"id":"13","name":"Fred"}]} Here is a simplified…
jshree
  • 9,781
  • 3
  • 18
  • 10
850
votes
22 answers

How to tell Jackson to ignore a field during serialization if its value is null?

How can Jackson be configured to ignore a field value during serialization if that field's value is null. For example: public class SomeClass { // what jackson annotation causes jackson to skip over this value if it is null but will //…
ams
  • 60,316
  • 68
  • 200
  • 288
737
votes
12 answers

Ignoring new fields on JSON objects using Jackson

I'm using Jackson JSON library to convert some JSON objects to POJO classes on an android application. The problem is, the JSON objects might change and have new fields added while the application is published, but currently it will break even when…
Hadi Eskandari
  • 25,575
  • 8
  • 51
  • 65
622
votes
8 answers

Representing null in JSON

What is the preferred method for returning null values in JSON? Is there a different preference for primitives? For example, if my object on the server has an Integer called "myCount" with no value, the most correct JSON for that value would…
pherris
  • 17,195
  • 8
  • 42
  • 58
542
votes
29 answers

Infinite Recursion with Jackson JSON and Hibernate JPA issue

When trying to convert a JPA object that has a bi-directional association into JSON, I keep getting org.codehaus.jackson.map.JsonMappingException: Infinite recursion (StackOverflowError) All I found is this thread which basically concludes with…
Ta Sas
  • 9,573
  • 15
  • 51
  • 73
476
votes
14 answers

JsonMappingException: No suitable constructor found for type [simple type, class ]: can not instantiate from JSON object

I am getting the following error when trying to get a JSON request and process it: org.codehaus.jackson.map.JsonMappingException: No suitable constructor found for type [simple type, class com.myweb.ApplesDO]: can not instantiate from JSON object…
Lucky Murari
  • 12,672
  • 5
  • 22
  • 43
463
votes
6 answers

Should I declare Jackson's ObjectMapper as a static field?

The Jackson library's ObjectMapper class seems to be thread safe. Does this mean that I should declare my ObjectMapper as a static field like this class Me { private static final ObjectMapper mapper = new ObjectMapper(); } instead of as an…
Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875
438
votes
10 answers

Only using @JsonIgnore during serialization, but not deserialization

I have a user object that is sent to and from the server. When I send out the user object, I don't want to send the hashed password to the client. So, I added @JsonIgnore on the password property, but this also blocks it from being deserialized into…
chubbsondubs
  • 37,646
  • 24
  • 106
  • 138
399
votes
5 answers

Jackson Vs. Gson

After searching through some existing libraries for JSON, I have finally ended up with these two: Jackson Google GSon I am a bit partial towards GSON, but word on the net is that GSon suffers from a certain celestial performance issue (as of Sept…
Suraj Chandran
  • 24,433
  • 12
  • 63
  • 94
364
votes
24 answers

Serializing with Jackson (JSON) - getting "No serializer found"?

I get the an exception when trying to serialize a very simple object using Jackson. The error: org.codehaus.jackson.map.JsonMappingException: No serializer found for class MyPackage.TestA and no properties discovered to create BeanSerializer…
Ted
  • 19,727
  • 35
  • 96
  • 154
352
votes
25 answers

serialize/deserialize java 8 java.time with Jackson JSON mapper

How do I use Jackson JSON mapper with Java 8 LocalDateTime? org.codehaus.jackson.map.JsonMappingException: Can not instantiate value of type [simple type, class java.time.LocalDateTime] from JSON String; no single-String constructor/factory method…
Alexander Taylor
  • 16,574
  • 14
  • 62
  • 83
321
votes
32 answers

No Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator

I am trying to consume an API using Retrofit and Jackson to deserialize. I am getting the onFailure error No Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator.
José Nobre
  • 4,407
  • 6
  • 20
  • 40
302
votes
9 answers

Convert a Map to a POJO

I've been looking at Jackson, but is seems I would have to convert the Map to JSON, and then the resulting JSON to the POJO. Is there a way to convert a Map directly to a POJO?
user86834
  • 5,357
  • 10
  • 34
  • 47
297
votes
14 answers

Converting JSON data to Java object

I want to be able to access properties from a JSON string within my Java action method. The string is available by simply saying myJsonString = object.getJson(). Below is an example of what the string can look like: { 'title':…
Faiyet
  • 5,341
  • 14
  • 51
  • 66
1
2 3
99 100