Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Jackson 2 equivalent of JSONObject?

Tags:

json

jackson

What class in the fasterxml API is equivalent to the org.json.JSONObject?

like image 954
edwardmlyte Avatar asked Jul 19 '12 16:07

edwardmlyte


People also ask

What is the difference between JSONObject and JSONObject?

JSONObject is "native" to Android SDK, JsonObject is probably the one from Gson library, the one that I use. Two different package, don't work with both ;) choose one. I had some issue with the date formatting in JSONObject.

What is Jackson JSON parser?

Jackson JSON Parser API provides easy way to convert JSON to POJO Object and supports easy conversion to Map from JSON data. Jackson supports generics too and directly converts them from JSON to object.

How does Jackson read nested JSON?

A JsonNode is Jackson's tree model for JSON and it can read JSON into a JsonNode instance and write a JsonNode out to JSON. To read JSON into a JsonNode with Jackson by creating ObjectMapper instance and call the readValue() method. We can access a field, array or nested object using the get() method of JsonNode class.

What is the use of Jackson ObjectMapper?

ObjectMapper is the main actor class of Jackson library. ObjectMapper class ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Plain Old Java Objects), or to and from a general-purpose JSON Tree Model (JsonNode), as well as related functionality for performing conversions.


1 Answers

It appears the class sought was ObjectNode, not JSONObject.

ObjectNode is now in the databind project, in the com.fasterxml.jackson.databind.node package. The latest JavaDoc is at http://fasterxml.github.com/jackson-databind/javadoc/2.0.2/com/fasterxml/jackson/databind/node/ObjectNode.html

like image 83
Programmer Bruce Avatar answered Oct 15 '22 14:10

Programmer Bruce