Skip to content

Instantly share code, notes, and snippets.

@DeepSpawn
Last active June 27, 2016 22:32
Show Gist options
  • Save DeepSpawn/46d0f07123a227d9daa7392a2b471b2a to your computer and use it in GitHub Desktop.
Save DeepSpawn/46d0f07123a227d9daa7392a2b471b2a to your computer and use it in GitHub Desktop.
public static String show(final Json json) {
return json.match(
seq -> seq.getElems().stream()
.map(j -> show(j))
.collect(Collectors.joining(",", "[", "]")),
jobject -> jobject.getMembers().entrySet().stream()
.map(kv -> "\"" + kv.getKey() + "\":" + show(kv.getValue()))
.collect(Collectors.joining(",", "{", "}")),
jnumber -> jnumber.getNum().toString(),
jstring -> "\"" + jstring.getStr() + "\"",
jboolean -> jboolean.getB().toString(),
jNull -> "null"
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment