Class SimpleJsonWriter

java.lang.Object
net.targetr.wtm3.io.SimpleJsonWriter

public class SimpleJsonWriter extends Object
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 Details

    • SimpleJsonWriter

      public SimpleJsonWriter()
      Constructs a new SimpleJsonWriter.
  • Method Details

    • toJson

      public static String toJson(Map<String,Object> data)
      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

      public static void writeJsonArray(List<Object> list, StringBuilder b)
      Writes a List as a JSON array.
      Parameters:
      list - data to write
      b - StringBuilder to append to
    • writeJsonObject

      public static void writeJsonObject(Map<String,Object> data, StringBuilder b)
      Writes a Map as a JSON object.
      Parameters:
      data - Map to write
      b - StringBuilder to append to