delight-json
delight-json is an extremely simple library to render human-readable JSON with Java.
Why: A simple and very portable way to generate beautiful, human-readable JSON.
delight-json is part of Java Delight.
Usage
JSON Objects
JSON json = JSON.create();
json.add("text", "hello");
json.add("number", 123);
json.print();
Results in:
{
'text': 'hello',
'number': '123'
}
Nested JSON Objects
JSON documents may be added as values to other JSON documents.
final JSON json = JSON.create();
json.add("text", "hello");
json.add("inner", JSON.create().add("number", 1234));
json.print();
Results in:
{
'text': 'hello',
'inner': {
'number': '1234'
}
}
JSON Arrays
Arrays can be added as values of JSON documents.
JSON json = JSON.create();
json.add("array", JSON.createArray().push("1").push("2").push("3"));
json.print();
Results in:
{
'array': [
'1',
'2',
'3'
]
}
Rendering
Documents can either be printed to standard out:
json.print();
Or rendered as String:
String str = json.render();
Maven Dependency
<dependency>
<groupId>org.javadelight</groupId>
<artifactId>delight-json</artifactId>
<version>[latest version]</version>
</dependency>
This artifact is available on Maven Central and BinTray.
Compatibility
This project is compatible with the following environments:
- Java 1.6+
- GWT 2.5.0+
- Android (any)
- OSGi (any)
Further Resources
Licenses
-
Apache 2.0
-
MIT