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
6
votes
1 answer

Jackson FAIL_ON_UNKNOWN_PROPERTIES to false not working

I am trying to make thrift deserialization for jackason backward compatible ObjectMapper mapper = getObjectMapper(false /* pretty */); mapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true); // This works // This doesn't…
user10714010
  • 865
  • 2
  • 13
  • 20
6
votes
3 answers

Jackson - deserialize inner list of objects to list of one higher level

With Spring Boot and Jackson, how can I deserialize a wrapped/inner list into a list directly in the outer level? For example, I have: { "transaction": { "items": { "item": [ { "itemNumber": "193487654", …
WesternGun
  • 11,303
  • 6
  • 88
  • 157
6
votes
1 answer

How to globally apply @JsonIgnoreProperties(value = { "id" }) for all POJO classes of application (jackson api)

I have multiple classes and for all of them I don't want id field to be the part of my output JSON string (serialization). Let say I have 2 classes @JsonIgnoreProperties(value = { "id" }) public final class Person { private ObjectId id; …
Shashank
  • 712
  • 15
  • 33
6
votes
2 answers

Should I parse json string to json object or manipulate the string directly

normally I parse a json string to json object instead of manipulating the json string directly. for example, a json string like {"number": "1234567"} if I have to add 000 at the end ... {...,"number" : "1234567000",...} .... I will use jackson…
Holm
  • 2,987
  • 3
  • 27
  • 48
6
votes
2 answers

Jackson: how to include null value property in JSON serialization

I'm trying to generate a JSON response using my own Java entity classes together with Jackson annotations. Two key values must be null in my JSON response but if I set them to null they disappear from JSON. I'm limited to Jackson version 1.9.13…
pbjerry10
  • 137
  • 1
  • 1
  • 8
6
votes
2 answers

Missing artifact com.fasterxml.jackson.core:jackson-databind:bundle:2.9.8

Working with Jackson library, it came following error in Eclipse 4.9.0 version Missing artifact com.fasterxml.jackson.core:jackson-databind:bundle:2.9.6 pom.xml /Jackson-Usage line 7 Maven Dependency Problem The problem came when I added maven…
vimal krishna
  • 2,886
  • 28
  • 22
6
votes
1 answer

Avoid Jackson xmlMapper being used as default objectMapper with Spring

I had to add this dependency to my pom.xml in order to deserialize xml files in my software. com.fasterxml.jackson.dataformat jackson-dataformat-xml However it seem to…
Adam B.
  • 61
  • 4
6
votes
1 answer

Configuring Jackson mapper when using Dropwizard

I would like to use the Java 8 java.time with Jersey/Jackson in the context of a Dropwizard app. I understand I need to use jackson-modules-java8 and configure the mapper object. But how do I configure Jersey's automagic mapper that deserialises the…
Friedrich 'Fred' Clausen
  • 3,321
  • 8
  • 39
  • 70
6
votes
1 answer

Automatically serialize Rest controllers to CSV instead of JSON in Spring Boot

I am looking for a quick/easy solution how to automatically serialize Rest controllers output to CSV instead of JSON. I have the simplest possible Spring boot application: @SpringBootApplication public class CsvExportApplication { public static…
Adam Siemion
  • 15,569
  • 7
  • 58
  • 92
6
votes
3 answers

JsonNode comparison excluding fields

I'm trying to deserialise a JSON string using ObjectMapper (Jackson) and exclude a field while performing the deserialisation. My code is as follows: String aContent = new String(Files.readAllBytes(Paths.get(aFile))); String bContent = new…
Mkl Rjv
  • 6,815
  • 5
  • 29
  • 47
6
votes
1 answer

Deserialization of arrays with Jackson

i have something like JSON-RPC client, and i´m having trouble deserializing incoming json string into my java object. The incoming json format is: {"value":"xxxx","type":"xxxx"} The object i want to deserialize…
mirekys
  • 87
  • 1
  • 3
  • 7
6
votes
3 answers

Spring boot 2.04 Jackson cannot serialize LocalDateTime to String

I have Spring boot application and LocalDateTime properties serialized as JSON array, instead of String. As I found while search on web, all I need is to set up in…
P_M
  • 2,723
  • 4
  • 29
  • 62
6
votes
3 answers

How to handle jackson deserialization error for all kinds of data mismatch in spring boot

I know there is some similar questions here about how to parse ENUM, how to parse customize JSON structure. But here my question is how to just give a better message when the user submit some JSON with is not as expected. This is the…
aisensiy
  • 1,460
  • 3
  • 26
  • 42
6
votes
2 answers

Generate JSON sample from Java class

How can you generate a JSON sample with dummy data from a Java class definition? (Note: I am not asking about generating JSON from a POJO. This is something that has been asked before on stackoverflow). What I want is to generate some sample dummy…
gil.fernandes
  • 12,978
  • 5
  • 63
  • 76
6
votes
4 answers

JSON Serialization of BitSet doesn't work

I would like to serialize/deserialize java.util.Bitset in JSON format. This code: BitSet bs = new BitSet(10); bs.set(1); bs.set(5); ObjectMapper mapper = new ObjectMapper(); mapper.writeValue(System.out, bs); prints {"empty":false} as…
1 2 3
99
100