Questions tagged [jackson2]

Use this tag only for questions specifically related to version 2 of the Jackson library

Jackson version 2 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.

464 questions
78
votes
3 answers

What is the difference between ObjectNode and JsonNode in Jackson?

According to the documetation of JsonNode: Most mutators, however, need to be accessed through specific sub-classes (such as ObjectNode and ArrayNode). However I am still confused since some stackoverflow answers seem to use them quite…
THIS USER NEEDS HELP
  • 3,136
  • 4
  • 30
  • 55
29
votes
4 answers

How to make default time zone apply in Spring Boot Jackson Date serialization

I have configured my Spring Boot application to serialize dates as ISO8601 strings: spring: jackson: serialization: write-dates-as-timestamps: false This is what I am getting: "someDate": "2017-09-11T07:53:27.000+0000" However my time…
codependent
  • 23,193
  • 31
  • 166
  • 308
20
votes
3 answers

Jackson , java.time , ISO 8601 , serialize without milliseconds

I'm using Jackson 2.8 and need to communicate with an API that doesn't allow milliseconds within ISO 8601 timestamps. The expected format is this: "2016-12-24T00:00:00Z" I'm using Jackson's JavaTimeModule with WRITE_DATES_AS_TIMESTAMPS set to…
Benjamin M
  • 23,599
  • 32
  • 121
  • 201
19
votes
4 answers

Jackson, deserialize class with private fields and arg-constructor without annotations

It is possible to deserialize to a class with private fields and a custom argument constructor without using annotations and without modifying the class, using Jackson? I know it's possible in Jackson when using this combination: 1) Java 8, 2)…
Devabc
  • 4,782
  • 5
  • 27
  • 40
17
votes
6 answers

Force Milliseconds When Serializing Instant to ISO8601 using Jackson

I have some questions related to JSON serialization using Jackson in a project where I use Spring Boot 2.0.0.M6, Spring Framework 5.0.1.RELEASE and Jackson 2.9.2. I have configured the following Jackson-related settings in…
André Gasser
  • 1,065
  • 2
  • 14
  • 34
15
votes
2 answers

Jackson cannot convert empty string value to enum

I am looking for a handy solution with Jackson (2.8) to filter out fields pointing to empty String value before/during deserialization: @JsonInclude(JsonInclude.Include.NON_EMPTY) public class Guis { public enum Context { SDS, …
crishushu
  • 435
  • 2
  • 4
  • 14
14
votes
3 answers

How to use @JsonIdentityInfo with circular references?

I am trying to use the @JsonIdentityInfo from Jackson 2 as described here. For testing purposes I created the following two classes: public class A { private B b; // constructor(s) and getter/setter omitted } public class B { private A…
Burkhard
  • 14,596
  • 22
  • 87
  • 108
13
votes
2 answers

'com.google.api.client.json.jackson2.JacksonFactory' is deprecated. What are my options?

While following the Gmail API java quickstart guide I came across this code snippet: private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance(); Using it in the editor gave me a warning that it is deprecated. What are my…
12
votes
5 answers

Error during Deserialization of PageImpl : Cannot construct instance of `org.springframework.data.domain.PageImpl`

Issue is when using Spring cache with redis cache manager, not able to deserializer Spring Pageable response due to no default constructor The spring boot version used is 2.1.4.RELEASE Redis config class that uses the serializer @Bean public…
12
votes
4 answers

Why is Spring Boot not using a @Primary Jackson ObjectMapper for JSON serialization on a rest controller?

I have a class set up to return a customised ObjectMapper. As far as I can find, the correct way to have Spring Boot use this ObjectMapper is to declare it as @Primary, which it is. @Configuration public class MyJacksonConfiguration { …
Dan
  • 7,446
  • 6
  • 32
  • 46
11
votes
3 answers

Jackson custom filter with full POJO data bind

This question extends this question. While the previous solution works great if you only have a couple of fields, it becomes unmaintainable when you have more than a dozen of fields. Right now, my current set up uses full data binding, so I have a…
THIS USER NEEDS HELP
  • 3,136
  • 4
  • 30
  • 55
10
votes
2 answers

Jackson create JavaType from Class

There must be a way to create a JavaType from String.class? Note: The input for the method must be JavaType for my use case because that value is created dynamically using TypeFactory. /** Returns a JavaType for Map **/ private…
cambunctious
  • 8,391
  • 5
  • 34
  • 53
10
votes
1 answer

Generate an empty set of Json braces- using java & JSON

How to generate an empty json node using jackson-java. I tried with NullNode.instance, but that returns "totals":null Whereas I want totals to be an empty instance. { "totals": {}, "orderId": "550047004", "numberOfItems": 2 }
Vikash
  • 2,046
  • 3
  • 23
  • 30
10
votes
1 answer

how to replace jackson in spring boot application as automatic marshaler and unmarshaler with jsoniter

I am using jackson , which come along with spring boot , to convert from json to java object and vice versa , but i found that this is taking much time when json is huge in size like for 2 MB json to related java object by marshaling , can we use…
Bravo
  • 8,589
  • 14
  • 48
  • 85
8
votes
1 answer

Jackson error: Cannot deserialize instance of `java.lang.String` out of START_ARRAY token

Hey I have also problem here is my Json [ { "aimid": "12345" }, { "aimid": "333674" }, { "aimid": [ "4568999", "6789345" ] }] and This is my Pojo class:- @JsonProperty("aimid") private String aimid; public String…
Deepak Kumar
  • 83
  • 1
  • 1
  • 8
1
2 3
30 31