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
0 answers

Spring MVC 4.3 Rest dynamic filtering of fields

I'm using Spring MVC 4.3.2 with @RestController and I would like to be able to dynamically filter JSON properties specified by our clients in the request. To keep things easy, let's say I have a Person POJO that contains firstName and lastName…
Nis
  • 560
  • 5
  • 18
2
votes
1 answer

Invalid mime type in spring rest template?

I am just trying to make a simple REST request like below String url = "some url"; MultiValueMap headers = new LinkedMultiValueMap<>(); headers.add(HttpHeaders.CONTENT_TYPE,…
Soham
  • 671
  • 1
  • 7
  • 23
2
votes
2 answers

Parsing Json file with Jackson

I call a WS that returns a Json object like follows: { "id": "salton", "name": "salton", } which I parse without any problem using ObjectMapper mapper = new ObjectMapper(); return mapper.readValue(jsonStr,…
2
votes
0 answers

How to deserialize an object array into a Map using Jackson, using one of the object's properties as key?

I am deserializing a Json object which contains as one of it's properties an array of objects, like so: { name: 'abc', symbols: { { a: '1', b: 'test'}, { a: '2', b: 'test'}, { a: '3', b: 'test'} ... ] } If I deserialize into a…
Edy Bourne
  • 5,679
  • 13
  • 53
  • 101
2
votes
1 answer

How to ignore a NULL value during Deserialization in lamda stream?

I have getter method @JsonInclude(Include.NON_NULL) public Date getVerifiedFrom() { if(invoices == null || invoices.isEmpty()) { return null; } return invoices.stream().filter(i->i.getVerifiedDate() !=…
Thirumal
  • 8,280
  • 11
  • 53
  • 103
2
votes
0 answers

Retrofit 2 , Jackson can't deserialize inner jsonString & can't remove escape character

Server Response data: { "data": "{\"domain\":{\"Logical\":\"small_logical.png\",\"Physical\":\"small_physical.png\"}" } onFailure: Can not instantiate value of type [simple type, class com.mobile.app.model.Responses.Data] from String value…
Chokkar G
  • 56
  • 6
2
votes
1 answer

Jackson, deserialize plain JSON array to a single Java object

An external service is providing a JSON array with plain/primitive elements (so without field names, and without nested JSON objects). For example: ["Foo", "Bar", 30] I would like to convert this to an instance of the following Java class using…
Devabc
  • 4,782
  • 5
  • 27
  • 40
2
votes
1 answer

Weblogic 12.2.1.3 from Moxy to Jackson

I would like to change the JSON parser from Moxy to Jackson, and I have followed the shared library approach, but without any result, Moxy is still used. Note: the shared library is not necessary!!! The shared library I have created a maven project…
2
votes
1 answer

Jackson Deserialiser : use @JsonCreator AND @JsonProperty on field?

I'm trying to parse some Json into an Java object. Some fields require custom behavior so i tried to use @JsonCreator on a constructor. Well, it work, but for the other field annotate with @JsonProperty are not populated. Didn't check yet, but i…
J.Mengelle
  • 341
  • 3
  • 11
2
votes
1 answer

Jackson deserialize array with empty object

I have the following JSON: {"beans":["{}",{"name":"Will"}]} and the corresponding POJO classes: public class BeanA { private BeanB[] beans; ...getters/setters } public class BeanB { private String name; ...getters/setters } I…
Will Huang
  • 325
  • 7
  • 15
2
votes
1 answer

Jackson failed to deserialization OneToMany relationship entity

I'm having a oneToMany reltionShip between two entities: public class Product { @JsonBackReference private List listProductDetail; And public class ProductDetail { @JsonManagedReference private Product product; I'm…
Zizou
  • 831
  • 1
  • 10
  • 19
2
votes
1 answer

How to use Jackson Package in this scenario?

Hi I have a Json like follows: A { B { C [{ x1:x2, y1:y2 }] } } Now my requirement is to convert the A, B, C to camelCase notation(as required) which I did by using @JsonProperty and getter…
Pavan
  • 543
  • 4
  • 16
2
votes
2 answers

Unexpected token (END_OBJECT), expected FIELD_NAME: missing property '@type'

I am getting below exception during deserialization , the guest profile is a nested object within the Root object (few levels within it). i dont have control over how it is serialized since I am only the consumer of this message from a kafka topic. …
user2221654
  • 311
  • 1
  • 7
  • 20
2
votes
1 answer

Jackson Deserialize property value with raw json to object

I've defined to JSON Pojo classes as shown below, In the below MyMessage class, sometimes I receive kpMessage class as string, how can I convert the received string to object. @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({…
Karthik Prasad
  • 9,662
  • 10
  • 64
  • 112
2
votes
2 answers

Can Jackson/Gson give me all known deserializable field names?

If I have a POJO: public class Item { @JsonProperty("itemName") public String name; private int quantity; @JsonGetter("quantity") //call it "quantity" when serializing public int getQuantity() {...} @JsonSetter("number") //call it…
kaqqao
  • 12,984
  • 10
  • 64
  • 118