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
2
votes
2 answers

Java Jackson Deserialize Plain Json Array or Json Object into a Single Java Object (POJO)

I am retrieving data from an API endpoint that returns data in two different expected json formats. One of the responses is a success response and one of the responses is a failure response. The other endpoints in the API are similar and also have a…
Nick
  • 23
  • 3
2
votes
3 answers

Conflicting property name definitions in jersey ,using Jackson 2.9.6

I have a REST service with the following modal: /** * Agent */ public class Agent { @JsonProperty("name") private String name = null; @JsonProperty("type") private String type = null; @JsonProperty("description") private String…
user10182984
  • 41
  • 1
  • 5
2
votes
1 answer

Jackson yaml library unable to parse a valid yaml file

I'm parsing an YAML file with jackson yaml parser jackson-dataformat-yaml and it's failing to parse the following YAML file. environments: linux: - [rbenv,python-2.7] env: global: # The username below should have write access to your…
harshavmb
  • 3,404
  • 3
  • 21
  • 55
2
votes
1 answer

Gson, Jackson, Flaten Map/HashMap

Say I have a POJO as follows - public class Pojo { String name; String address; Map values; //getter/setters } If, I convert it to a String in JSON format using Jackson, as follows - Pojo pojo= new Pojo (); …
CR Sardar
  • 921
  • 2
  • 17
  • 32
2
votes
1 answer

ManyToOne referenced entities not exist in JSON Response when returning PagedResource

When I return a Page from a method inside my @RestController class, all fields of Entity both referenced via @OneToXXX and @ManyToXXX take place in the returned JSON object. But when I switched the return type to PagedResource (to be able to…
alegria
  • 931
  • 2
  • 10
  • 25
2
votes
1 answer

MapStruct map correct instance of object based on target type

How to correct map different classes with same parent spring DTO jackson objects @JsonTypeInfo( use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", ) @JsonSubTypes(value = { …
Kaiser
  • 748
  • 7
  • 21
2
votes
1 answer

How to serializer and deseralize a sub class of set as a known set with jackson 2

I am trying to serializde a jpa managed class (openjpa). This class contains a set. At runtime this set's type is org.apache.openjpa.util.java$util$LinkedHashSet$proxy (we're using openjpa). Jackson will serialize this fine but then will fail when…
Michael Wiles
  • 20,902
  • 18
  • 71
  • 101
2
votes
1 answer

@XmlElementWrapper Serialization not working using Jackson JaxB Annotations

We are using Jackson 2.9.4 and JaxB Annotations to serialize to JSON. The @XMLElementWrapper annotation is not adding an extra wrapping level as expected. Instead, it is just changing the name of the element. @XmlRootElement(name = "revision") …
Gonen I
  • 5,576
  • 1
  • 29
  • 60
2
votes
2 answers

jackson kotlin - Cannot deserialize instance of `java.util.ArrayList` out of START_OBJECT token

I am getting a json string from Fitbit API. I want to save dateTime and value fields in a List object. I´m using jackson module kotlin. I have created ActivitiesSteps data class for this. I don´t know how to avoid "activities-steps" field and I´m…
2
votes
2 answers

Two Jackson ObjectMapper generate different serializations

I have two ObjectMapper instances of Jackson. (Using v2.8.3) The first one is instantiated as follows: ObjectMapper objectMapper = new ObjectMapper(); The other one is autowired from the Spring Boot context via @Autowired. Both have the same…
suat
  • 4,239
  • 3
  • 28
  • 51
2
votes
1 answer

Send a String to a Spring(Jackson) REST controller in a POST method

I am attempting to send a String object to a rest service using HTTP Post method. and the String should be sent in the request body. The controller @RestController @RequestMapping(value = "post", method = RequestMethod.POST) public class…
user5132301
2
votes
1 answer

Spring unable to convert JSON with Jackson present in maven

I'm having troubles with returning a JSONObject in Java Spring. I've been googling fanaticly but haven't found a solution yet. I'm using Jackson's fasterxml but I still can't get my API to respond in JSON. I'll include the files which I think are…
J. Doe
  • 43
  • 5
2
votes
2 answers

Jackson JsonDeserializer delegate deserialization of a field back to default deserializer of that field type

Given public class ConstraintMatch { protected String constraintName; protected Score score; ... } I have the following serializer in Jackson: public class ConstraintMatchJacksonJsonSerializer extends JsonSerializer { …
Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
2
votes
1 answer

Use Jackson Deserialization for DateTime in Spring REST Controller

I am getting this exception when trying to deserialize the value passed on the POST request to the Spring controller from String to OffsetDateTime. Here is my exception: Failed to convert value of type 'java.lang.String' to required type…
divinedragon
  • 5,105
  • 13
  • 50
  • 97
2
votes
1 answer

Jackson jsonformat deserialize always in UTC

Jackson's jsonformat annotation works not quite as I expected. Let's say in Java SimpleDateFormat: SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy"); Date date = sdf.parse("1-Mar-2018"); The date object value is 1-Mar-2018 SGT. Which is…
Sam YC
  • 10,725
  • 19
  • 102
  • 158