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

Jackson @JsonRawValue for Map's value

I have the following Java bean class with gets converted to JSON using Jackson. public class Thing { public String name; @JsonRawValue public Map content = new HashMap(); } content is a map who's values will be raw JSON from…
Steve Kuo
  • 61,876
  • 75
  • 195
  • 257
7
votes
3 answers

Changing from Gson to Jackson for JSON parsing

Im currently using GSON to parse a pretty big JSONfile using an inputstream/reader. The parsing takes about 35 seconds on my android device, i understood from some benchmark test that Jackson performance is way better. But i can't find out how to…
Jasper
  • 2,389
  • 4
  • 25
  • 40
7
votes
3 answers

How to Deserialize JSON Array?

I'm using Jackson within CXF to serialize/deserialize data. Unfortunately, I am having difficulty configuring CXF/Jackson to deserialize a JSON array. I'd appreciate help in resolving the issue. Up to this point most of the json data has been in…
Ari
  • 4,121
  • 8
  • 40
  • 56
7
votes
4 answers

Formatting JSON before writing to File

Currently I'm using the Jackson JSON Processor to write preference data and whatnot to files mainly because I want advanced users to be able to modify/backup this data. Jackson is awesome for this because its incredibly easy to use and, apparently…
Brandon
  • 4,486
  • 8
  • 33
  • 39
7
votes
1 answer

Jackson handling Wrapped elements

I'm parsing the response from last.fm API. But it seems that they used some wrapper for some of the responses, which is causing a bit of a pain. To put an example: { "artists":{ "artist":[ { "name":"Coldplay", …
Vinicius Carvalho
  • 3,994
  • 4
  • 23
  • 29
7
votes
1 answer

One domain model, multiple json views

We have a set of domain classes which are serialized to json via jackson using jersey services. We are currently annotating the classes with JAXB (although we're not tied to that). This works fine. But we want to offer different serializations of…
Rick Mangi
  • 3,761
  • 1
  • 14
  • 17
7
votes
1 answer

Jersey & Jackson - Resource modifying Jackson output

I'm currently using Jersey & Jackson for creating REST service. Right now when a Resource method produces application/json and is returned a POJO, it properly serializes the object into JSON and returns the response to the client. What I'm looking…
William
  • 15,465
  • 8
  • 36
  • 32
7
votes
2 answers

How to find a node by name in a Json Tree?

I am doing inverse geocoding using google geocoding APIs. The results are returned in Json which I'm parsing in following manner - Map parsedJson = new ObjectMapper().readValue( response.getEntity(String.class), …
Kshitiz Sharma
  • 17,947
  • 26
  • 98
  • 169
7
votes
2 answers

Deserialize ArrayList from String using Jackson

I am using Spring's MappingJacksonHttpMessageConverter to convert JSON message to object in my controller.
ltfishie
  • 2,917
  • 6
  • 41
  • 68
7
votes
4 answers

Jackson field based serialization

I think Jackson does method based serialization, is there any way I could make it field based? Ex: class Bean { Integer i; String s; public Integer getI() { return this.i; } public void setI(Integer i) { this.i = i; } public…
jack_carver
  • 1,510
  • 2
  • 13
  • 28
7
votes
4 answers

Jackson2 custom deserializer factory

I am porting jackson 1.6 code to jackson 2 and stumbled upon a deprecated code. What i did in jackson 1.6 is: CustomDeserializerFactory sf = new CustomDeserializerFactory(); mapper.setDeserializerProvider(new…
timoffei
  • 147
  • 2
  • 6
6
votes
3 answers

Missing error requests in the tomcat's localhost_access log, while IOException during the Jackson invocation appears in the application log

Some weird situation. During a performance test of a web application (war), the client gets 500 on about 2% of the requests. When searching the application log, there are some exceptions there: java.io.IOException: Stream closed at…
Tarlog
  • 10,024
  • 2
  • 43
  • 67
6
votes
1 answer

support both xml and json REST response in clojure

Say I have a REST API in java, and it supports responses that are either JSON or XML. The responses contain the same data, but the form is not identical. For example, in json I might have: { "persons": [ { "name":"Bob", …
Kevin
  • 24,871
  • 19
  • 102
  • 158
6
votes
1 answer

Jackson complex list serialization

I'm experementing with Jackson serialization/deserialization. For instance, I have such class: class Base{ String baseId; } And I want to serialize List objs; To do it with jackson, I need to specify a list's elements real type, due to the java…
tmp120210
  • 147
  • 1
  • 3
  • 9
6
votes
3 answers

Java JSON -Jackson- Nested Elements

My JSON string has nested values. Something like "[{"listed_count":1720,"status":{"retweet_count":78}}]" I want the value of the retweet_count. I'm using Jackson. The code below outputs "{retweet_count=78}" and not 78. I'm wondering if I can get…
Mob
  • 10,958
  • 6
  • 41
  • 58