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

Why is JSON invalid when commas in string?

Anyone know why this JSON is invalid? {"street_address":"Stone House Lane, Peckforton
, Tarporley
, London, Cheshire"} I'm using Jackson for Java and it's complaining about java.lang.IllegalArgumentException:…
Popcorn
  • 5,188
  • 12
  • 54
  • 87
7
votes
2 answers

Get Jackson XMLMapper to set root element name in code

How do I get Jackson's XMLMapper to set the name of the root xml element when serializing? There's an annotation to do it, if you're serializing a pojo: @XmlRootElement(name="blah"). But I'm serializing a generic Java class, LinkedHashMap, so I…
ccleve
  • 15,239
  • 27
  • 91
  • 157
7
votes
1 answer

Jackson : Updating (not creating new object) JavaObject from Json?

OK I have a json say userjson = { fname : "ABC", lname : "DEF" } and a User Pojo Object User { String id, String email, String fname, String lname } now using the Jackson, I know how to create User instance from userjson, but how do i update…
LNT
  • 876
  • 8
  • 18
7
votes
1 answer

How can I tweak the JSON that gets generated by Jackson's JAXRS provider?

I'm using jersey, and jackson for formatting JSON output. The Java source looks like this: import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.json.Json; import…
Cheeso
  • 189,189
  • 101
  • 473
  • 713
7
votes
2 answers

System.out messed up after Jackson serialization

I've been trying to serialize some Objects to System.out (for debugging). As soon as I call final JsonSerializer serializer = new JsonSerializer(); serializer.serialize( System.out, myObj ); System.out.println("done"); it prints out the json, but…
gorootde
  • 4,003
  • 4
  • 41
  • 83
7
votes
2 answers

Is there a way to make a "generic" json object?

Currently I am doing something like that: public class MyObject{ public String name; //constructor here } So, if I serialize it: ObjectMapper mapper = new ObjectMapper(); MyObject o = new MyObject("peter"); mapper.writeValue(System.out,o); I…
Phate
  • 6,066
  • 15
  • 73
  • 138
7
votes
1 answer

Conflicting getter definitions for property in Jackson 2.2.3

For simplicity here is a simple class: class GetterMethodsObject { int id = 10; public int getId() { return id; } // @JsonIgnore public boolean isId() { return true; } } Serializing this object should…
user3435827
  • 111
  • 1
  • 1
  • 3
7
votes
2 answers

Wildfly and Jackson: LinkageError

I'm trying to configure jboss wildfly 8 to use Jackson for JSON. So I added org.jboss.resteasy resteasy-jackson-provider 3.0.6.Final
EasterBunnyBugSmasher
  • 1,507
  • 2
  • 15
  • 34
7
votes
2 answers

Spring Boot Web- Set FAIL_ON_UNKNOWN_PROPERTIES to false in Jackson

I have read Spring boot doc (http://projects.spring.io/spring-boot/docs/docs/howto.html#message.converters ) and its mentioned that if you provide your own JacksonConvertor, it will override the default one. But I guess its not working with the…
hellojava
  • 4,904
  • 9
  • 30
  • 38
7
votes
1 answer

Spring MVC REST JPA Hibernate Jackson infinite recursion one-to-many JSON error

I have a one to many bi-directional relationship between a parent entity and child entities(ie.parent has one or more children and child has only one parent) in a Spring MVC REST Service which uses JPA and Hibernate for persistence. Whenever I try…
hamo
  • 474
  • 1
  • 6
  • 16
7
votes
1 answer

Creating a @JsonMixin annotation for spring controllers

I am using spring with jackson for json responses. I want to create an annotation to allow a feature of jackson called mixins. The idea is similar to this question Using Jackson Mixins with MappingJacksonHttpMessageConverter & Spring MVC public…
jax
  • 37,735
  • 57
  • 182
  • 278
7
votes
3 answers

How do I iterate over a JSON response using Jackson API (of a List inside a List)?

How do I iterate over a JSON response in Java using Jackson API? In other words, if the response has a list and inside that list is another list ( in this case called 'weather') , then how do I get the temperature? Here is an example of what I am…
djangofan
  • 28,471
  • 61
  • 196
  • 289
7
votes
2 answers

Jackson: deserialize array of Strings to List

For a JSON object, Subject: { "permissions":["foo", "bar"], ... } ... I would like to deserialize to: class Subject { private List permissions; ... ... where Permission is: class Permission { .... public…
markdsievers
  • 7,151
  • 11
  • 51
  • 83
7
votes
1 answer

yaml parsing using com.fasterxml.jackson

I am trying to parse yaml files into models using jackson Model -- public class TestModel { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; …
amrk7
  • 1,194
  • 5
  • 13
  • 33
7
votes
1 answer

Jackson- JsonSerializable- when should we implement serializeWithType method

I am using JsonSerializable interface to customise my JSON output. I am able customise the JSON serialisation by overriding "serialize" method. But I wanted to know the scenarios where "serializeWithType" method is needed to be implemented as well.…
Johnny P
  • 73
  • 1
  • 4