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

Performance difference - Jackson ObjctMapper.writeValue(writer, val) vs ObjectMapper.writeValueAsString(val)

Is there any significant performance difference between the following two? String json = mapper.writeValueAsString(searchResult); response.getWriter().write(json); vs mapper.writeValue(response.getWriter(), searchResult);
Sagar
  • 5,315
  • 6
  • 37
  • 66
5
votes
2 answers

Mapping RestTemplate response to java Object

I am using RestTemplate get data from remote rest service and my code is like this. ResponseEntity> responseEntity = restTemplate.exchange(request, responseType); But rest service will return just text message saying no record found…
user9735824
  • 1,196
  • 5
  • 19
  • 36
5
votes
1 answer

How to dynamically map JSON array of key values to sub-object using Jackson?

Say we have a JSON structure that looks like this: { "field1": "val1", "field2": "v2", "f3": "v3", "f4": "v4", "arrayOfStuff": [ { "f5": "v5", .... "f10": "v10" } ], "attributes": [ {"att1": "att1"}, {"att2": "attr2"}, …
Carmageddon
  • 2,627
  • 4
  • 36
  • 56
5
votes
3 answers

Resteasy with wildfly14: not all fields are returned

I'm migrating my application from wildfly 10 to wildfly 14 and I'm using resteasy 3.1.4 with jackson2. I have a strange behaviour with the response of some rest services: not all the fields are returned (and I'm sure they're extracted from mongodb).…
Giamma
  • 808
  • 2
  • 10
  • 21
5
votes
1 answer

Jackson private constructors, JDK 9+, Lombok

I'm looking for documentation on how Jackson works with private constructors on immutable types. Using Jackson 2.9.6 and the default object mapper provided by spring boot two running with jdk-10.0.1 Given JSON: {"a":"test"} and given a class…
David
  • 7,652
  • 21
  • 60
  • 98
5
votes
1 answer

Jackson LocalDate/Time deserialization

I configured jackson so that it gives me a smiple string representation if java.time.LocalDate and java.time.LocalDateTime. This works find in the serialization process, e.g when I get data on the REST api. It doesn't work the other way round…
Mrvonwyl
  • 347
  • 2
  • 15
5
votes
2 answers

How to use Jackson 2 in Payara 5?

I'm using Jackson 2 with Payara 4 and I would liked to use Jackson 2 in Payara 5. Using JAX-RS, I also would like to avoid changing annotations and so on... In Payara 5 the default Jsonb provider is Yasson. Any ideas to disable it and use Jackson…
Whyvra FVR
  • 73
  • 1
  • 8
5
votes
1 answer

Lombok v1.6.20 does not work with Jackson

When using constructor generated by newest Lombok v1.6.20, Jackson is not able to use the constructor. For example, when deserializing @Data @AllArgsConstructor private static class TestObject { private Integer a; private String b; } I am…
Lukas
  • 13,606
  • 9
  • 31
  • 40
5
votes
0 answers

gson got com.google.gson.internal.LinkedTreeMap

I have the following json { "kind": "youtube#channelListResponse", "etag": "\"cbz3lIQ2N25AfwNr-BdxUVxJ_QY/QM4kW8nb-nymx1biZnF8bIvgOfE\"", "pageInfo": { "totalResults": 1, "resultsPerPage": 1 }, "items": [ { "kind":…
Vihaan Verma
  • 12,815
  • 19
  • 97
  • 126
5
votes
1 answer

How to disable conversion of 0/1 to true/false in jackson 2.9.x

I have a project that needs a strict json policy. Example: public class Foo { private boolean test; ... setters/getters ... } Following json should work: { test: true } And following should fail (throw exception): { test:…
Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115
5
votes
1 answer

Converting Nested json into dot notation json

I have a service from where I get a json string response like as shown below { "id": "123", "name": "John" } I consume the rest call using HttpClient and converts the json string to Map like as shown below. String url=…
Alex Man
  • 4,746
  • 17
  • 93
  • 178
5
votes
0 answers

Jackson - Deserialize with JsonView

I am trying to restrict which properties from a JSON object are deserialised using Jackson JSONViews. The aim is to use this to prevent consumers of my API from submitting data that they shouldn't. The problem is, I have either misunderstood…
user2294382
  • 871
  • 3
  • 11
  • 25
5
votes
4 answers

@JsonIgnoreProperties(ignoreUnknown=false) is not working in Spring 4.2.0 and upper version

@JsonIgnoreProperties(ignoreUnknown=false) is not working with spring 4.2.0 and upper version of spring. But it is working with 4.0.4 and 4.0.1 . I am using spring 4.2.8 and Jackson dependencies are used
Masbha
  • 51
  • 1
  • 3
5
votes
2 answers

Custom UnmodifiableSetMixin Fails in Jackson 2.7+

I'd like to be able to deserialize an UnmodifiableSet with default typing enabled. To do this I have created an UnmodifiableSetMixin as shown below: NOTE: You can find a minimal project with all the source code to reproduce this issue at…
Rob Winch
  • 21,440
  • 2
  • 59
  • 76
5
votes
1 answer

Difference between ObjectMapper().createObjectNode vs. JsonNodeFactory.instance.objectNode()?

I saw a post about inserting new nodes to JsonNode and encountered two separate answers, but I can't grasp the difference between the two. From my little experience, ObjectMapper doesn't allow you to create anything but ObjectNode and ArrayNode…
THIS USER NEEDS HELP
  • 3,136
  • 4
  • 30
  • 55
1 2
3
30 31