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

JSON response with dash in the key-name

I am using feign for my rest-calls. Unfortunately one of the responses I get looks something like this: { "customer-id" : "0123" } The JSON response automatically gets mapped to one of my POJO's. This response object can not have a property…
Robert van der Spek
  • 1,017
  • 3
  • 16
  • 37
8
votes
2 answers

Altering an array in a nested JSON object using Jackson

I am trying to figure out how to alter an existing object in a JSON array by specifying the path to that array. The problem is I have no idea how to specify the path to the array so it can be altered. Every method I've tried there are no examples…
user2100493
  • 1,258
  • 4
  • 15
  • 26
8
votes
2 answers

Spring Boot Controller - Enum parameter as Value

I have a spring boot controller, one of my parameters is an Enum. The enum has a string value. I want to pass as the parameter the value of the enum and the controller to give me the Enum. Can this be done? @RequestMapping(value = "/") public…
Panos
  • 7,227
  • 13
  • 60
  • 95
8
votes
3 answers

JsonView returning empty json objects

I am trying to implement a JsonView to selectively serialize fields from an entity but the json that is serialized has empty objects with no fields. Below is my code: ViewClass: public class AuditReportView { public interface Summary…
Jason
  • 220
  • 1
  • 14
8
votes
2 answers

Spring Boot 1.4 Customize Internal Jackson Deserialization

I am using spring.jackson.deserialization.FAIL_ON_UNKNOWN_PROPERTIES=true in the application.properties to make deserialization fail on unknown properties but its not working. I even tried using : @Bean ObjectMapper objectMapper() { return…
Kiba
  • 399
  • 1
  • 4
  • 16
8
votes
2 answers

Parsing a json which contains duplicate keys

I'm trying to parse json with invalid structure which has duplicate keys using Jackson library. If a json has duplicate keys, I would like to extract them as a Collection. Example of what I'm trying to parse (the actual json that I'm trying to…
Edd
  • 1,982
  • 2
  • 21
  • 29
8
votes
2 answers

Apache Johnzon vs Jackson

since Apache released the first final version of Johnzon, it would be really interesting to see if there are already some comparison between Johnzon and FastXML Jackson to see if it is worth to switch. The most important topic is probably the…
smichel
  • 745
  • 1
  • 7
  • 14
8
votes
2 answers

Custom serializer for serializing a List in List

I've a Model object Group public class Group { String title; List members; String createdBy; } I'm using Jackson to serialize this Object. Instead of serializing the whole User object in list "members" I want to serializer just…
crysis
  • 1,514
  • 1
  • 20
  • 35
8
votes
2 answers

swagger-codegen client: How to include jackson annotations on models

I'm using swagger-codegen to generate a rest client, but I get a problem, the service I'm consuming returns a model with an inheritance, the API model looks like this: public class Person { private List books; ... } @JsonTypeInfo(use…
satellite satellite
  • 893
  • 2
  • 10
  • 27
8
votes
3 answers

Jackson: Serializing object fields to array

I'm pretty new to Jackson, but I stumbled upon the following problem: I'd like to serialize a simple object to an array of its fields. So considering the following class: public class UserModel { private String id; private String firstName; …
Jaims
  • 1,515
  • 2
  • 17
  • 30
8
votes
3 answers

Deserialization issue from XML to POJO with Jackson: no String-argument constructor/factory method to deserialize from String value

I've got an XML document which I need to convert (deserialize) into Java POJO. I cannot change the structure of the XML document. I use Java 8, and Jackson framework for mapping. Gradle dependencies: dependencies { …
ucas
  • 417
  • 1
  • 11
  • 30
8
votes
1 answer

Jackson Yaml Type Info is wrong on serialization

I am getting the following output when serializing an object to yml via Jackson: --- commands: dev: ! However, what I want is: --- commands: dev: type: foo.bar.baz.DevCommand I am able to deserialize that fine. …
mtyson
  • 8,196
  • 16
  • 66
  • 106
8
votes
2 answers

How to map json to object using spring boot

Hello I'd like to know how I could mapp my json message to object in java when using spring boot. Let's say I'm getting json like { "customerId": 2, "firstName": "Jan", "lastName": "Nowak", "town": "Katowice" } and I'd like to…
filemonczyk
  • 1,613
  • 5
  • 26
  • 47
8
votes
5 answers

How to consume list of entities response from spring-data-rest

I am using spring-data-rest to expose REST API. One of my search method returns list of entities. The repository and rest response as follows List findByKeywordContaining(String keyword); Search Response: { "_embedded":{ …
Achaius
  • 5,904
  • 21
  • 65
  • 122
8
votes
5 answers

Jackson @JsonFilter is not getting applied when used at field or method level

I am using Spring version 4.3.3 and Jackson version 2.8.3. I am trying to filter out specific fields from an entity bean based on some custom logic that is determined at runtime. The @JsonFilter seems ideal for this type of functionality. The…
Jonathan
  • 1,078
  • 11
  • 9