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
2 answers

org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "id" (Class Criteria), not marked as ignorable

I am getting this exception when I am trying to parse Json to Java pojo object. The object graph has couple objects. org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "id" (Class Criteria), not marked as ignorable I…
Oliver.Oakley
  • 628
  • 2
  • 7
  • 23
8
votes
1 answer

How to map the Mixins for the nested JSON response

I am using Jackson APIs for Mapping my JSON response into a java object. For example, for the response { name :'karthikeyan',age:'24',gender:'Male'} @JsonProperty("name") public String _name; @JsonProperty("age") public int…
Karthikeyan
  • 2,634
  • 5
  • 30
  • 51
8
votes
2 answers

Custom deserialization on top of reflective deserialization with Jackson

I want to run some custom code when deserializing a particular type with Jackson 1.9. However, I don't want to hand-write the whole deserializer, just add to the default behaviour. Trying to do this in a JsonDeserializer the naive way results in…
Tavian Barnes
  • 12,477
  • 4
  • 45
  • 118
8
votes
2 answers

How to return 400 HTTP error code when some property of a RequestBody parameter is null?

I have the following example: This is the request body: public class UserLoginData implements Serializable { private static final long serialVersionUID = 1L; private String username; private String password; //... getter and…
Neuquino
  • 11,580
  • 20
  • 62
  • 76
8
votes
3 answers

How to make Spring MVC return CSV as convenient as return JSON

I know Spring MVC could return a model in format of Json easily; however, I have tried quite different approaches to return a model in CSV format (via Jackson), but could not make it successfully. What should I do? I enclose my model code,…
Ye Huang
  • 639
  • 2
  • 10
  • 21
8
votes
3 answers

Jackson: generate schemas with references

When using Jackson's JSON schema module, instead of serializing the complete graph I'd like to stop whenever one of my model classes is encountered, and use the class name to insert a $ref for another schema. Can you guide me to the right place in…
dnault
  • 8,340
  • 1
  • 34
  • 53
8
votes
2 answers

RESTEasy and ContextResolver for Jackson

I have a problem with the customization of my RESTEasy JSON response. In web.xml I use autoscan: resteasy.scan true Here is my customization class for…
Ging3r
  • 2,010
  • 2
  • 17
  • 26
8
votes
1 answer

Jackson csv writer doesn't use correct column separator

I'm trying to write a CSV file using Jackson 2.2.2 (especially jackson-dataformat-csv) but i can't get it to use the ';' as fileseparator. i'm using the following code to initialize the writer: CsvMapper mapper = new CsvMapper(); CsvSchema schema =…
Ozzie
  • 11,613
  • 4
  • 21
  • 24
8
votes
4 answers

Exception thrown when serializing Hibernate object to JSON

Well I'm using Hibernate to load a tiny database to some classes representing the tables and interact with the database. All fine, and I can really see all results... And I don't have any null field, all of them are been used. Here I show the "main"…
Fernando Carvalho
  • 393
  • 1
  • 3
  • 14
8
votes
2 answers

Jackson - Deserialize nested JSON

I have a JSON string which will be of the following format: { "response": { "execution_status": "ready", "report": { "cache_hit": true, "created_on": "2013-07-29 08:42:42", "fact_cache_error": null, …
Anand
  • 1,791
  • 5
  • 23
  • 41
8
votes
2 answers

Jackson parsing JSON containing an array of objects and array of maps w/ dynamic keys

I have json like this: { "users":{ "1234":{ "firstname":"Joe", "lastname":"Smith" }, "9876":{ "firstname":"Bob", "lastname":"Anderson" …
pat
  • 1,005
  • 4
  • 12
  • 29
8
votes
2 answers

jackson serializing Collections.unmodifiable*

I have a problem using the Jackson serialization from json, how do I serialize from Collections.unmodifiableMap? The error I get is: com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of…
hartraft
  • 83
  • 2
  • 8
8
votes
1 answer

Using Jackson XmlMapper to serialize to an XML DOM

I know it's possible to serialize directly to a String using XmlMapper.writeValueAsString(), but I would like to serialize a DOM tree. Either a new Document or, preferably, serialize directly to an existing DOM Node. Can this be done with Jackson?
hertzsprung
  • 9,445
  • 4
  • 42
  • 77
8
votes
1 answer

Dynamically enable/disable he UNWRAP_ROOT_VALUE and WRAP_ROOT_VALUE in Jackson's ObjectMapper?

Is there a way to enable/disable the UNWRAP_ROOT_VALUE and WRAP_ROOT_VALUE in Jackson's ObjectMapper dynamically. I have to enable/disable these properties depending on what service is called, some requests require a JsonRootName and some do not. I…
user86834
  • 5,357
  • 10
  • 34
  • 47
8
votes
2 answers

Looking for a good example of polymorphic serialization deserialization using jackson with scala

Looking for a good example of polymorphic serialization deserialization using jackson with scala got an exception : Exception in thread "main" Blockquote org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field…
igx
  • 4,101
  • 11
  • 43
  • 88