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
1
vote
1 answer

how to allow duplicate keys with jackson while deserializing xml

I have a simple xml file structured like this with multiples B keys 0000 test 1111111111
ulquiorra
  • 931
  • 4
  • 19
  • 39
1
vote
1 answer

Configuring ObjecMapper null serialization after first serialization does not have effect

Stumbled on this behavior when making some experiments with ObjectMapper. See Junit5 test cases below and what those print for me in comments. class TestIt { private ObjectMapper om = new ObjectMapper(); private TestClass testClass = new…
pirho
  • 11,565
  • 12
  • 43
  • 70
1
vote
1 answer

Query about flattening a nested json using Jackson

I've a json { "parentId": "123", "parentName": "abc", "child": { "childId": "456", "childName": "xyz", } } My requirement is to flatten the json so that I can map it to a pojo class MyJson{ private String…
Sandy
  • 459
  • 2
  • 6
  • 19
1
vote
1 answer

How to solve conflicting getter definitions for property in jackson without access to source

I'm getting this error: HTTP Status 500 - Could not write JSON: Conflicting getter definitions for property "oid" The problem is that the class has two similar methods: getOID (deprecated) and getOid But I cannot modify the class as it's just a…
Lucas
  • 668
  • 1
  • 5
  • 17
1
vote
0 answers

How to serialize property base on context Bean type when use jackson?

For a specific property type (such as MyType), I want to serialize it to diff output base on what Bean it define in. class A { MyType t; } class B { MyType t; } Want to serialize A.t to value1, B.t to value2 base on the type of A or B. I found…
RJ.Hwang
  • 1,683
  • 14
  • 24
1
vote
1 answer

How to provide enum string as value of an attribute?

Enum:- public StatusEnum { MISSING("00"), INVALID("01"); .... } I'm trying to use these strings "MISSING", "INVALID" as an attribute field for JSR Validations:- public class SomePojo{ @NotNull(message = StatusEnum.MISSING.toString()) …
Jerald Baker
  • 1,121
  • 1
  • 12
  • 48
1
vote
1 answer

Jackson scala module: deserialize case object enumeration

I am using Jackson scala module and I need to serialize/deserialize case object enumerations. The serialization works fine, but when deserializing back the values I get a com.fasterxml.jackson.databind.exc.InvalidDefinitionException. There is a way…
1
vote
1 answer

How Jackson handles mapping conflict?

I have the following class with a property "key" that maps to 2 different JSON fields public class A { @JsonAlias("Key") private String key; @JsonProperty("NewKey") private void unpackNewKey(Map NewKey) { …
user3908406
  • 1,416
  • 1
  • 18
  • 32
1
vote
2 answers

Customize Jackson XML output when using @JsonView in Spring Boot

I am using the @JsonView annotation to output a simplified version of a complex object in Spring MVC. The View: public class UserView { public interface Summary {} } The entity class: public class User implements Serializable { private…
kioleanu
  • 920
  • 1
  • 6
  • 17
1
vote
1 answer

How to create the POJO to handle JSON data having array of elements as well as array of array of elements

We have a scenario where we have JSONs with 2 different values for a field. We would like to parse all the jsons using the same POJO. Below you can find these 2 JSON payloads: { "values": [ [ { "name": "item_name", …
Amit Kumar
  • 1,544
  • 11
  • 23
1
vote
1 answer

How to inject dependency into Jackson Custom serializer

In this question I've seen an interesting approach for injecting objects into custom deserializers for the Jackson mapping framework (I'm currently on version 2.10.x). Essentially, one registers a dependency MyService in the ObjectMapper …
JeanValjean
  • 17,172
  • 23
  • 113
  • 157
1
vote
1 answer

How to ignore case for POJO if it extends an abstract class in Spring Jackson?

I know we can ignore case for input JSON by adding property in application.yml as: spring: jackson: mapper: accept_case_insensitive_properties: true But if my POJO extends an abstract class, it is not working and my JSON is not being…
P3arl
  • 383
  • 3
  • 18
1
vote
1 answer

jackson deserialization with specific deserializer playframework 2.8

I have a specific json come from prestashop webservoice and i don't manage do deserialize correctly with playframework 2.8 { "orders": [ { "id": 44, "id_address_delivery": "95", …
cyril
  • 872
  • 6
  • 29
1
vote
1 answer

Jackson XML Serialization: Nested Element with Same Name as Parent

I have a complex xml type with a nested element whose name is the same as the parent, but when I serialize it the nested element gets set as the text of the parent when it is included in another element. The DTOs looks like…
Pytry
  • 6,044
  • 2
  • 37
  • 56
1
vote
0 answers

Wildfly 18 Jackson2 ObjectMapper ignored

I have this ObjectMapper configuration: @Provider public class JacksonConfig implements ContextResolver { private final ObjectMapper objectMapper; public JacksonConfig() { objectMapper = new ObjectMapper() …
Michal
  • 53
  • 4