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

Jackson : Inheritance and required attributes

I'm currently trying to implement a deserializer using jackson able to handle polymorphism, that is, given these two classes : public abstract class Animal { private String name; private float weight; @JsonCreator protected…
MatJeg
  • 31
  • 5
3
votes
0 answers

JSON not returning child object details for same type

I have a JPA entity which is returned as a ResponseEntity from a REST end point. The end point returns a collection of that entity - Code below public ResponseEntity> getAllEmployees() { Collection returnedEmployees =…
3
votes
0 answers

How can I define a default value in a YAML map?

For a YAML configuration file, I would like to do the following: configuration.yml endpoints: - name: MyFirstService context: my-app - name: MySecondService context: default: my-app prod: my-app-p I need to configure a special context…
Yotus
  • 264
  • 1
  • 4
  • 17
3
votes
3 answers

JJWT / Jackson alter the ObjectMapper used

For a project I am working on, I am required to use Spring Security and JSON Webtokens as provided by the library io.jsonwebtoken (jjwt). One of the claims I am required to add to my generated token is the following entity (simplified to illustrate…
Pieter De Clercq
  • 1,951
  • 1
  • 17
  • 29
3
votes
1 answer

How to ignore specific sub-field of an unwrapped field (CSV)

How do I tell Jackson to skip an unwrapped sub-POJO field so when I parse to CSV, it skips the entire column? Here's a full code example: public class FooTest { class Foo { String something = "value"; @JsonUnwrapped(prefix = "bar.") …
Jeep87c
  • 1,050
  • 16
  • 36
3
votes
1 answer

com.fasterxml.jackson.databind.JsonMappingException: Numeric value (1557587751202) out of range of int

I've generated a Spring Boot web application using Spring Initializr, using embedded Tomcat + Thymeleaf template engine in a macOS Sierra., where I have to parse Json object I have a domain object with this…
Salvador Borés
  • 165
  • 1
  • 3
  • 9
3
votes
1 answer

Deserialize property file that contains dot with Jackson

In our application we are trying to read a flat property file using Jackson to match the properties to our POJO Everything works fine, but when the property name contains some dot, the wholo POJO is set to null Here is a sample of the property…
David
  • 83
  • 1
  • 6
3
votes
2 answers

Configure a Jackson's DeserializationProblemHandler in Spring environment

As I understood, Spring is already providing a bean for Jackson ObjectMapper. Therefore, instead of creating a new bean, I'm trying to customize this bean. From this blog post, and then this Github project I used Jackson2ObjectMapperBuilder bean to…
woshilapin
  • 239
  • 4
  • 19
3
votes
0 answers

Jackson map a meta object to all requests

I am using jackosn and spring boot. I want to recieve a request object that contains both meta object with information such as requestId and request time, and an object data. the object data changes between the different requests. I am talking about…
Ido Barash
  • 4,856
  • 11
  • 41
  • 78
3
votes
1 answer

Add multiple mixins to one class with Jackson

I have to minins: @JsonIdentityInfo(generator=ObjectIdGenerators.None.class, property="@id") public interface NoReferenceMixin { } @JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, …
Troy Daniels
  • 3,270
  • 2
  • 25
  • 57
3
votes
1 answer

Does Jackson Deserialization into a JsonNode Guarantee Property Ordering?

For example, if I deserialize the following JSON into a JsonNode: { "property1": 1, "property2": 2, "property3": 3 } and then traverse the elements with JsonNode#fields, is there any guarantee that the iterator will return the properties…
mark.monteiro
  • 2,609
  • 2
  • 33
  • 38
3
votes
1 answer

json4s org.json4s.package$MappingException: Do not know how to convert JString into double

I am trying a very simple example, but not able to make it work; Below is my JSON format, I am using the Scala json4s parser for parsing JSON; json4s fails to parse a JSON string if any JSON field is not a string. For example json4s fails to parse…
nilesh1212
  • 1,561
  • 2
  • 26
  • 60
3
votes
1 answer

Wrong time when using @JsonFormat (+1 hour)

I have a class that contains the following attribute: @JsonFormat(pattern= "yyyy/MM/dd hh:mm") private java.util.Date begin; Now I do a POST to my rest service: mockMvc.perform(post("/rest/foo") …
NoobieNoob
  • 887
  • 2
  • 11
  • 31
3
votes
1 answer

Correct JAX-RS media type matching for JSON provider

The official JSON media type is application/json. The RESTEasy provider for Jackson, ResteasyJackson2Provider, specifies the media types like this: @Provider @Consumes({"application/*+json", "text/json"}) @Produces({"application/*+json",…
Garret Wilson
  • 18,219
  • 30
  • 144
  • 272
3
votes
2 answers

Serialize JsonNode to a very specific JSON format in Jackson

I have JsonNode result that I want to print out. So far, I am using: ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationFeature.INDENT_OUTPUT); File outputFile = new File( getCurOutputDir(), String.format("out.json",…
THIS USER NEEDS HELP
  • 3,136
  • 4
  • 30
  • 55