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

Retained Heap size is more while using jackson ObjectMapper

Am using Jackson mapper to convert my java objects to String, But these objects are not removed by GC in heap. My code List reportList; // This contains my objects ObjectMapper map = new ObjectMapper(); //…
Akalya
  • 876
  • 8
  • 12
8
votes
2 answers

Unable to see JSON conversion error in Spring MVC REST

I am doing AngularJS and Spring REST application. Here is my code. @RestController @RequestMapping("/user") // @Secured("ROLE_ADMIN") public class UserController { @RequestMapping(value = "/verifyUser", method = RequestMethod.POST) …
Rajendra Thorat
  • 3,248
  • 3
  • 15
  • 24
8
votes
1 answer

Dealing with json field that is either an array or an object?

So with this api that I’m using I often encounter json containing a field that is either an array or an object, and I’m not sure how to deal with this the right way. What happens is that I have an array in my json which is an empty array if there…
florian
  • 434
  • 2
  • 12
8
votes
3 answers

How to tell Jackson to deserialize "null" string to null literal?

I have a webservice which prints "null" as a string for any property instead of null literal. It does that for almost all data types(String or Date). For example, in ideal case it returns { "item" : { "title": "Some title", …
Max
  • 3,371
  • 2
  • 29
  • 30
8
votes
1 answer

Jackson Modules for Map Serialization

I have a Class that contains a Map (with non String key) and some other fields. public class MyClass() { private Map map; private String someField; public MyClass(Map map, String…
forhas
  • 11,551
  • 21
  • 77
  • 111
8
votes
1 answer

How To Use Jackson's @JsonIdentityInfo for Deserialization of directed Graphs?

I want to use Jackson 2.3.3 for Deserialization/Serialization of directed graphs. The structure I came up with is roughly the following: public Class Graph { private final Set nodes; public Graph(Set nodes) { ... } public…
MalteJ
  • 111
  • 1
  • 1
  • 7
8
votes
1 answer

RestTemplate and acessing json

I have seen the responses from many other posts but would like to understand if there is a better way to do the same thing. Requirement:- I am using restTemplate to talk to web service which returns JSON output which is dynamic. As a consumer I…
Milind
  • 531
  • 2
  • 12
  • 24
8
votes
1 answer

include class name in all objects serialized by jackson

How to include class name in all serialized objects? E.g. adding "_class: 'MyClass'" to output value. Is there some global setting for that? I don't want to add any annotation to pojo classes. I'm using it with spring4 webmvc @ResponseBody (only…
8
votes
1 answer

Getting error in jackson library code

We are using dropwizard version 0.6.3. When we try to upgrade version 0.7.0, we are getting this error on service start. Exception in thread "main" java.lang.VerifyError: class…
Manikandan
  • 3,025
  • 2
  • 19
  • 28
8
votes
4 answers

Override Jackson Object Mapper properties on Websphere 8.5.5 using Apache Wink

We are using IBM(s) bundled Apache Wink to offer JAXRS endpoints for our application. We are coding towards Websphere 8.5.5. Since we are servlet 3.0 compliant we use the 'programmatic' way of configuring the JaxRS application, meaning no entries in…
javapapo
  • 1,342
  • 14
  • 26
8
votes
4 answers

JSON - Unable to serialize JSONObject within Object using Jackson

I have the following class: class A{ String abc; String def; // appropriate getters and setters with JsonProperty Annotation } and I call Jacksons objectMapper.writeValueAsString(A) which works fine. Now I need to add another…
dev ray
  • 465
  • 3
  • 6
  • 18
8
votes
2 answers

Parsing Json File using Jackson

{ "TestSuite":{ "TestSuiteInfo":{ "-description":"parse" }, "TestCase":[ { "TestCaseData":{ "-sequence":"sequential", "-testNumber":"2", …
kumarabhishek
  • 125
  • 1
  • 1
  • 7
8
votes
1 answer

Json and abstract class 'Can not construct instance'

I have read a lot about this problem on stackoverflow but any solution works for me. Could anybody please tell me why it's not working since I have described all children object properly - or maybe not ? This are my dependency for…
johnnyGor
  • 161
  • 1
  • 3
  • 16
8
votes
4 answers

Jackson: Serialize only marked fields

I am trying to do something which was quite easy in gson. Since I switched to Jackson as serializer, I couldn't figure out how to implement this: I want to serialize only fields that have been marked by an Annotation. GSON code would be: class Foo…
gorootde
  • 4,003
  • 4
  • 41
  • 83
8
votes
1 answer

Jackson ObjectMapper Conflicting setter definitions (Android.Graphics.Bitmap)

I have this method : public static Response deserializeResponse(String jsonResponse) throws JsonParseException, JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(); try{ return…
francis lanthier
  • 101
  • 1
  • 1
  • 5