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

UnsupportedMediaTypeException: Content type 'application/octet-stream' not supported for bodyType=java.util.Map))

I am facing below error while running junit for controller. I have already set content-type as Json, still error is same. Any suggestion what could be the issue ? Error is java.lang.AssertionError: expectation "expectNext({response=employee saved…
user2800089
  • 2,015
  • 6
  • 26
  • 47
7
votes
0 answers

Problem with Java Iterator created by Jackson breaks Scala Flink application

There is a Scala Flink application where I am parsing JSON using Jackson library. Parsing is handled by a custom method and it uses the lazy initiation concept to keep it fast. Now, for whatever reason, passing model with lazy values further in…
Atais
  • 10,857
  • 6
  • 71
  • 111
7
votes
1 answer

apache camel and jackson

I'm trying out apache-camel, and I've set up a basic route that calls an http service via http4 component, transforms the result via unmarshal().json(JsonLibrary.Jackson), and then prints out part of the response in a bean component. The problem…
Kevin
  • 24,871
  • 19
  • 102
  • 158
7
votes
3 answers

From Spring BindingResult to field JSONPath/JSON Pointer, with Jackson

I have a Spring Boot application using javax.validation annotations and I'm trying to return friendly JSON error messages pointing to the offending field, yet converting from the available "Java-object" path to either JSONPath or JSON Pointer is…
mdrg
  • 3,242
  • 2
  • 22
  • 44
7
votes
3 answers

JsonMappingException occurs while converting object to JSON string - org.apache.avro.AvroRuntimeException: Not an array:

While converting Java object to JSON string, I'm facing JsonMappingException. Below is the complete exception message. com.fasterxml.jackson.databind.JsonMappingException: Not an array:…
Nicolas
  • 554
  • 2
  • 11
  • 27
7
votes
1 answer

Jackson databind : Cannot construct instance of `java.time.OffsetDateTime`

I am moving my project from dropwizard to mirconuat and I am getting below exception while consuming webservice response. i tried upgrading jackson version but it failed with warning and below cause. Caused by:…
2787184
  • 3,749
  • 10
  • 47
  • 81
7
votes
3 answers

Force Jackson serialize LocalDate to Array

I'm using spring-boot 2.1.6 and there is an API to accept a form including a date like: @Data public class MyForm { private LocalDate date; ... } @Controller public class MyController { @PostMapping("...") public ResponseEntity<...>…
auntyellow
  • 2,423
  • 2
  • 20
  • 47
7
votes
1 answer

Get element from JsonNode array

I have this json: { "text":[ {"a":1}, {"b":2} ] } I have this code: JsonNode jsonNode = (new ObjectMapper()).readTree(jsonString); //get first element from "text" //this is just an explanation of what i want String aValue…
KunLun
  • 3,109
  • 3
  • 18
  • 65
7
votes
1 answer

Make @JsonAnySetter work with @Value Lombok

I have a json object with a lot of properties (~80 properties) I want to deserialize in a POJO without creating manually all the properties. I was able to do this by using the @JsonAnySetter with a Map property like described here. Now I want to…
Monta
  • 1,136
  • 1
  • 12
  • 28
7
votes
1 answer

Need to Reject POST/PUT request if any unknown field is present in RequestBody

@Valid check is working for respective fields. Is there any way to reject requests if any unknown fields are present in JSON requestbody of POST/PUT requests.Below is my sample DTO class and controller. For below sample request body (for example),…
Balaji211
  • 257
  • 1
  • 5
  • 18
7
votes
3 answers

Deserialization null value to enum with Jackson

I have problem with JSON deserialization and mapping it to enum. I'm getting JSON from external API simillar to this two examples: { "someValue": null } { "someValue": "exists" } I would like to map null values to some default enum value. Model…
Kacper Fleszar
  • 156
  • 1
  • 8
7
votes
3 answers

JsonMappingException: Not a map, not an array or not an enum

I am working on a rest api application and i have some problems with the code. I want to return an object that extends avro schema and adds HATEOAS links to the response. I did some investigation and as it turns out i need custom serializer for…
user11725421
7
votes
2 answers

How do you register the KotlinModule to the AWS lambda Jackson Object Mapper?

I'm using Kotlin to write an AWS Lambda. I have a Kotlin data class class MessageObject( val id: String, val name: String, val otherId: String ) This data class is used as the input to the required interface implementation class Handler :…
dustinevan
  • 918
  • 9
  • 21
7
votes
6 answers

REST API for updating informations with empty or null values

I have a general question about how best to build an API that can modify records in a database. Suppose we have a table with 10 columns and we can query these 10 columns using REST (GET). The JSON response will contain all 10 fields. This is easy…
Hauke
  • 1,405
  • 5
  • 23
  • 44
7
votes
1 answer

Can Jackson be used with Spring MVC 3.0 to also bind the RequestBody to a Java Bean?

I have a very simple question, but I can't seem to find a simple answer: I got Jackson working to serialize Java beans to JSON in the response using @ResponseBody But I didn't manage to serialize back JSON to Java beans in the request using…
Eran Medan
  • 44,555
  • 61
  • 184
  • 276