molten-json
is a fluent Java 8 DSL for building JSON documents.
{
"name": "molten-json",
"version": "0.1.0",
"description": "A fluent Java 8 DSL for working with JSON.",
"repository": {
"type": "git",
"url": "https://github.com/helpermethod/molten-json"
},
"keywords": ["json", "java-8", "fluent", "dsl"],
"author": "helpermethod",
"license": "Apache 2",
"bugs": {
"url": "https://github.com/helpermethod/molten-json/issues"
}
}
String project = new Json()
.object(o -> o
.string("name", "molten-json")
.string("version", "0.1.0")
.string("description", "A fluent Java 8 DSL for working with JSON.")
.object("repository", r -> r
.string("type", "git")
.string("url", "https://github.com/helpermethod/molten-json"))
.array("keywords", k -> k.strings("json", "java-8", "fluent", "dsl"))
.string("author", "helpermethod")
.string("license", "Apache 2")
.object("bugs", b -> b
.string("url", "https://github.com/helpermethod/molten-json/issues")))
.toPrettyString();
<repositories>
<repository>
<id>bintray</id>
<url>http://dl.bintray.com/helpermethod/maven</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.helpermethod</groupId>
<artifactId>molten-json</artifactId>
<version>0.1.0</version>
</dependency>
</dependencies>
repositories {
maven {
url 'http://dl.bintray.com/helpermethod/maven'
}
}
dependencies {
compile 'com.helpermethod:molten-json:0.1.0'
}
JSONObject project = new Json().object().toJson();
JSONObject project = new Json().object(o -> o.string("name", "molten-json"));
JSONArray keywords = new Json().array().toJson();
JSONArray keywords = new Json().array(a -> a.strings("json"))
JSONArray keywords = new Json().array(a -> a.strings("json", "java-8", "fluent", "dsl"))
String project = new Json().object(o -> o.string("name", "molten-json")).toString();
String project = new Json().object(o -> o.string("name", "molten-json")).toPrettyString();
JSONObject project = new Json()
.object(o -> o
.string("name", "molten-json")
.string("version", "0.1.0"))
.object("repository", r -> r
.string("type", "git")
.string("url", "https://github.com/helpermethod/molten-json")))
.toJson();
String version = null;
JSONObject project = new Json(NullHandlingStrategy.IGNORE_NULL)
.object(o -> o
.string("name", "molten-json")
.string("version", version))
.toJson();