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

no String-argument constructor/factory method to deserialize from String value

I am trying to make use of an external NYtimes API. Here is an sample example data output : { "status": "OK", "copyright": "Copyright (c) 2016 The New York Times Company. All Rights Reserved.", "section": "home", "last_updated":…
Harry Gohil
  • 103
  • 1
  • 1
  • 7
7
votes
1 answer

Jackson's @JsonTypeInfo(use = Id.CUSTOM, include = As.PROPERTY, property = "type") reads all fields of JSON except for "type"

I stepped through each line of code, but I think it's how Jackson handles polymorphism internally. Using the classic example of Dog and Cat extending Animal: @JsonTypeInfo(use = Id.CUSTOM, include = As.PROPERTY, property =…
THIS USER NEEDS HELP
  • 3,136
  • 4
  • 30
  • 55
7
votes
3 answers

Jackson : custom collection serialization to JSON

I am trying to json-serialize a class MyRootClass with a property that is a collection of elements of a second class MyClass: public class MyRootClass { private List list = new ArrayList(); // getter /…
Guido
  • 46,642
  • 28
  • 120
  • 174
7
votes
1 answer

Jackson ObjectMapper adjusts dates to context timezone when deserializing even if explicitly disabled

This is the format of the date in JSON that I want to serialize/deserialize: "2014-06-18T06:26:56-07:00" The Joda DateTime field is declared as follows: @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssZ") …
Aydin
  • 311
  • 4
  • 15
7
votes
3 answers

why hibernate not set foreign key in the owner side of OneToMany

I have 2 Entities, Hospital and Department, Department reference its hospital by hospital_id in it. @Entity public class Hospital { ... private Set departments; @OneToMany(mappedBy = "hospital", cascade = CascadeType.ALL) …
DiveInto
  • 2,158
  • 3
  • 27
  • 50
7
votes
2 answers

In Kotlin, Jackson Deserialization error with data class

Not really sure how best to explain the problem so I whipped up the same code as both java and kotlin to better demonstration. When I read JSON, it appears that it is forcing a data beans value to be NULL even though the parameter is not even part…
Ryba
  • 1,249
  • 10
  • 17
7
votes
1 answer

Spring Boot REST Service: JSON Deserialization Not Working

I'm working on a REST service using spring-boot and Kotlin. (I should mention it's my first time using both.) I'm having trouble getting Jackson to deserialize JSON from a POST request using this code: @RequestMapping("cloudservice/login/{uuid}",…
irotsoma
  • 705
  • 2
  • 8
  • 15
7
votes
2 answers

Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "Status"

I am receiving following error message, I have Status class but it is not being recognized. I've got no idea how to proceed and could not find an answer online. Error org.springframework.http.converter.HttpMessageNotReadableException: Could …
Daniel Newtown
  • 2,873
  • 8
  • 30
  • 64
7
votes
2 answers

Using Jackson’s ObjectNode.putObject for method chaining

I have this code: static String createRequestJson(String apiKey, String apiSecret) { JsonNodeFactory factory = JsonNodeFactory.instance; ObjectNode root = factory.objectNode(); root.set("auth", factory.objectNode() .put("api_key",…
Roland Illig
  • 417
  • 1
  • 5
  • 15
7
votes
4 answers

How to enable dynamic pretty print of json based on http request header in Spring MVC?

I want to pretty print json responses from Spring MVC Restcontrollers dynamically based on a http parameter (like suggested here: http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api#pretty-print-gzip). I have found configurations…
7
votes
1 answer

JsonView not working correctly with Spring

I'm using Spring boot to create a restful api service. Everything works correctly, except that I cannot specify which data to be returned as JSON. What I want is to get the output without the field "content" ( which in my case is used for storing…
kkazakov
  • 459
  • 6
  • 15
7
votes
2 answers

JSON to Java object deserialization with escaped properties

I need to convert the following JSON to Java object. The property providerResponse in the JSON contains map of properties but they are escaped and wrapped in doubleQuotes. As a result, it does not deserialize the property providerResponse into a…
user1573133
  • 904
  • 1
  • 9
  • 23
7
votes
1 answer

How to serialize and deserialize Java Enums as JSON objects with Jackson

Given an Enum: public enum CarStatus { NEW("Right off the lot"), USED("Has had several owners"), ANTIQUE("Over 25 years old"); public String description; public CarStatus(String description) { this.description =…
ncphillips
  • 736
  • 5
  • 16
7
votes
2 answers

Jackson + SugarOrm id error

I use jackson and sugar orm and i have some errors when parsing. The id field is located in the json constantly 0. What can I do to fix it? This example my class: @JsonIgnoreProperties(ignoreUnknown = true) public class JsonScienceEvent extends…
Kota1921
  • 2,451
  • 1
  • 10
  • 13
7
votes
3 answers

Map JSON string column of a JPA entity to Java object automatically

I have a JPA entity object with following structure: @Table(name="item_info") class Item(){ @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private Long id; @Column(name="item_name") private String itemName; …
drunkenfist
  • 2,958
  • 12
  • 39
  • 73