Skip to content

Support for org.json data types, to ease migration out of code that uses them

Notifications You must be signed in to change notification settings

pivotal-linea/jackson-module-json-org

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Project to build Jackson (http://jackson.codehaus.org) extension module (jar) to support datatypes of "json org" JSON library (see [http://org.json/java])

h1 Usage

Register module with ObjectMapper:

ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JsonOrgModule());

And then you can read and write JSON to/from org.json.JSONObject:

JSONObject ob = mapper.readValue(json, JSONObject.class); // read from a source
String json = mapper.writeValue(ob); // output as String

As well as do conversion to/from POJOs:

MyValue value = mapper.convertValue(jsonObject, MyValue.class);
JSONObject jsonObject = mapper.convertValue(value, JSONObject.class);

or to/from Tree Model:

JsonNode root = mapper.valueToTree(jsonObject);
jsonObject = mapper.treeToValue(root, JSONObject.class);

(and all examples similarly with JSONArray, if root value is an array)

About

Support for org.json data types, to ease migration out of code that uses them

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%