Questions tagged [jackson]

Jackson is a Java library for handling tasks like reading and writing (parsing / generating) and data binding to/from Java objects. Although primarily used for JSON, Jackson also supports many other data formats such as Avro, CBOR, CSV, Java Properties, Protobuf, Smile, XML and YAML.

Jackson 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. It offers multiple processing modes including "streaming", "data-binding" and "tree model"; of these, latter two builds on streaming processing.

The Jackson homepage is hosted on GitHub, and the project's Wiki is here.

Alternatives

Alternative Java-to-JSON binding solutions with similar APIs include FastJSON, Google Gson, and svenson. Yet more Java-to-JSON libraries are listed at json.org.

Performance

The latest performance benchmarks for these and other JSON serialization and deserialization solutions for Java are available online.

16401 questions
8
votes
4 answers

How to automatically serialize and deserialize JSON string using JPA and Hibernate?

I have data class/table "User" that has column "preferences" CREATE table "user"; ALTER TABLE "user" ADD COLUMN preferences TEXT; Preferences type is TEXT and I am storing JSON there. public class User extends AbstractEntity{ public String…
Roman
  • 1,920
  • 2
  • 17
  • 17
8
votes
3 answers

How can I get a Jackson mixin to work with private fields?

I was experimenting with Jackson 2.0 mixins to serialize a class with no annotations. Simplified source code below. Note that I'm not using getters/setters, but it seemed like I should still be able to use mixins according to the…
user949300
  • 15,364
  • 7
  • 35
  • 66
7
votes
2 answers

Android Proguard - IllegalArgumentException in Jackson's TypeReference class

Android application crashes if proguard is used for obfuscating. Below is the stacktrace. Caused by: java.lang.IllegalArgumentException: Internal error: TypeReference constructed without actual type information at…
500865
  • 6,920
  • 7
  • 44
  • 87
7
votes
2 answers

Jackson : Conditional select the fields

I have a scenario where i need to use the payload as {"authType":"PDS"} or {"authType":"xyz","authType2":"abc",} or {"authType":"xyz","authType2":"abc","authType3":"123"} or any combination except for null values. referring to the code i have 3…
Rahul Reddy
  • 131
  • 2
  • 6
7
votes
2 answers

JSON Jackson Shared references

I have an Object that is reference by two other Objects I use Jackson to serialize my objects but have found my shared object is duplicated rather than reference. The reason is as I understand that Jackson can only serialize by value and not by…
HKalsi
  • 333
  • 3
  • 10
7
votes
2 answers

Spring MVC, deserialize single JSON?

How can I easily separate JSON values that are sent in the same request? Given that I POST a JSON to my server: {"first":"A","second":"B"} If I implement the following method in the Controller: @RequestMapping(value = "/path", method =…
matsev
  • 32,104
  • 16
  • 121
  • 156
7
votes
1 answer

Using Jackson ObjectMapper with Generics to POJO instead of LinkedHashMap

Using Jersey I'm defining a service like: @Path("/studentIds") public void writeList(JsonArray studentIds){ //iterate over studentIds and save them } Where JsonArray is: public class JsonArray extends ArrayList { public…
Will Shaver
  • 12,471
  • 5
  • 49
  • 64
7
votes
3 answers

How to add and ignore a field for json response

I'm using RestEasy and hibernate to return response in Jackson. I have a bean Player having fields: name, id, age, position. Now, I'm implementing two GET rest methods for returing json. getPlayer(), which is returning a player: name, id, age,…
Romi
  • 4,833
  • 28
  • 81
  • 113
7
votes
1 answer

Jackson trying to deserialize json into a List of typed objects

I am trying to use Jackson to deserialize a property on a object which is a List of typed objects. and i get the following error when I try to do it Can not instantiate value of type [map type; class java.util.HashMap, [simple type, class…
user1107753
  • 1,566
  • 4
  • 24
  • 36
7
votes
4 answers

Differentiating the Jersey, Jackson, and JaxB APIs

Hi : I've been using Jackson for JSON processing internally , and I want to serve these objects as Jsons to an external API (REST) (now, they are stored internally as java objects) . The obvious implementation would be to write some kind of query…
jayunit100
  • 17,388
  • 22
  • 92
  • 167
7
votes
1 answer

How to write custom serializer and deserializer in Jackson?

I have a class that has more than a dozen properties. For most of the properties of primitive type, I hope to use the default BeanSerializer and BeanDeserializer or whatever to reduce the cumbersome code I need to write. For other properties of…
PokerIncome.com
  • 1,708
  • 2
  • 19
  • 30
7
votes
1 answer

JACKSON Mapping XML config Without Annotations

I have a library of objects, whose source code is not editable so cant annotate them, is there another way to config Jackson Mapper like via XML.
Zafar ali
  • 77
  • 1
  • 7
7
votes
4 answers

Spring MVC: @ResponseBody, 415 Unsupported Media Type

I'm having trouble mapping a JSON Post to a particular Java Object to save it via Hibernate Headers of the Ajax call are correctly set... Accept application/json Content-Type application/json; charset=UTF-8 and the HTTP-Method is…
Jeremy S.
  • 6,423
  • 13
  • 48
  • 67
7
votes
1 answer

Jackson - Json to POJO With Multiple Entries

I know If the file User.json has { "name" : { "first" : "Joe", "last" : "Sixpack" }, "gender" : "MALE", "verified" : false, "userImage" : "Rm9vYmFyIQ==" } I can construct a single User object like this : User user = mapper.readValue(new…
Mohamed
  • 193
  • 3
  • 10
7
votes
1 answer

Jackson: Argument #0 has no property name, is not Injectable: can not use as Creator

full error Invalid type definition for type `com.xenoterracide.brix.configloader.spi.RawFileConfiguration`: Argument #0 has no property name, is not Injectable: can not use as Creator [constructor for…
xenoterracide
  • 16,274
  • 24
  • 118
  • 243