This library provides text related JSON handlers for other JSON processing libraries.
Consult the documentation and the usage description for further information:
This library is hosted in the Maven Central Repository. You can use it with the following coordinates:
<dependency>
<groupId>net.markenwerk</groupId>
<artifactId>utils-json-handler-text</artifactId>
<version>2.0.2</version>
</dependency>An AppendingJavaTextJsonHandler is a JsonHandler that appends a text, that represents the described JSON document by mimicing the toString() behavior of Java collection classes, to an Appendable.
// a JsonDocument
JsonDocument document = ...
// writes a pretty printed json document into test.json
Writer writer = new FileWriter(new File("test.json"));
document.handle(new AppendingJavaTextJsonHandler(writer));
writer.close();The appended String for the example.json has the following content:
{null=null, boolean=true, long=-42, double=-23.42, array=[foo, bar]}
A JavaTextJsonHandler is a JsonHandler that creates a String, containing a text that represents the described JSON document by mimicing the toString() behavior of Java collection classes.
// a JsonDocument
JsonDocument document = ...
// returns a pretty printed json document
String json = document.handle(new JavaTextJsonHandler(writer));The returned String for the example.json has the following content:
{null=null, boolean=true, long=-42, double=-23.42, array=[foo, bar]}
An AppendingJsonTextJsonHandler is a JsonHandler that appends a JSON text, that represents the described JSON document, to an Appendable.
// a JsonDocument
JsonDocument document = ...
// writes a pretty printed json document into test.json
Writer writer = new FileWriter(new File("test.json"));
document.handle(new AppendingJsonTextJsonHandler(writer));
writer.close();The appended String for the example.json has the following content:
{
"null" : null,
"boolean" : true,
"long" : -42,
"double" : -23.42,
"array" : [
"foo",
"bar"
]
}A JsonTextJsonHandler is a JsonHandler that creates a String, containing a JSON text that represents the described JSON document.
// a JsonDocument
JsonDocument document = ...
// returns a pretty printed json document
String json = document.handle(new JsonTextJsonHandler(writer));The returned String for the example.json has the following content:
{
"null" : null,
"boolean" : true,
"long" : -42,
"double" : -23.42,
"array" : [
"foo",
"bar"
]
}