Package net.targetr.wtm3.io
Class SimpleJsonWriter
java.lang.Object
net.targetr.wtm3.io.SimpleJsonWriter
Minimal JSON writer for monitoring data, supporting nested maps, lists, numbers and null.
Other values, including booleans, are written as strings. Keys are not escaped;
string escaping covers only quotes, carriage returns and newlines.
- Author:
- Dr Michael Gardiner
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringSerializes a map using this writer's limited type and escaping support.static voidwriteJsonArray(List<Object> list, StringBuilder b) Writes a List as a JSON array.static voidwriteJsonObject(Map<String, Object> data, StringBuilder b) Writes a Map as a JSON object.
-
Constructor Details
-
SimpleJsonWriter
public SimpleJsonWriter()Constructs a new SimpleJsonWriter.
-
-
Method Details
-
toJson
Serializes a map using this writer's limited type and escaping support.- Parameters:
data- Map of data to convert to JSON.- Returns:
- JSON version of the object.
-
writeJsonArray
Writes a List as a JSON array.- Parameters:
list- data to writeb- StringBuilder to append to
-
writeJsonObject
Writes a Map as a JSON object.- Parameters:
data- Map to writeb- StringBuilder to append to
-