Skip to content

A fluent Java 8 DSL for building JSON documents.

License

Notifications You must be signed in to change notification settings

vaccovecrana/sabnock

 
 

Repository files navigation

sabnock

sabnock is a minimal DSL for building JSON documents.

Available in Maven Central:

dependencies {
  implementation("io.vacco.sabnock:sabnock:<VERSION>")
}

Example

public class Example {
  public static void main() {
    var o = obj(
        kv("name", "molten-json"),
        kv("version", "0.1.0"),
        kv("description", "A fluent Java 8 DSL for working with JSON."),
        kv("repository", obj(
            kv("type", "git"),
            kv("url", "https://github.com/helpermethod/molten-json")
        )),
        kv("keywords", new String[] { "json", "java8", "fluent", "dsl" }),
        kv("author", "helpermethod"),
        kv("license", "Apache 2"),
        kv("bugs", obj(
            kv("url", "https://github.com/helpermethod/molten-json/issues")
        ))
    );

    var g = new GsonBuilder().setPrettyPrinting().create();
    var out = (SkOut.SkString) g::toJson;

    System.out.println(out.toJson(o));
  }
}

Output:

{
  "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",
    "java8",
    "fluent",
    "dsl"
  ],
  "author": "helpermethod",
  "license": "Apache 2",
  "bugs": {
    "url": "https://github.com/helpermethod/molten-json/issues"
  }
}

About

A fluent Java 8 DSL for building JSON documents.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 85.2%
  • Kotlin 14.8%