Class JSONWriter

java.lang.Object
com.blackrook.json.JSONWriter

public class JSONWriter extends Object
A class for writing JSON data to JSON representation.
Author:
Matthew Tropiano
  • Constructor Details

    • JSONWriter

      public JSONWriter(JSONWriter.Options options)
      Creates a new JSONWriter with a set of options to be used for every write.
      Parameters:
      options - the writer options to use.
      Since:
      1.2.0
  • Method Details

    • writeJSON

      public static void writeJSON(JSONObject jsonObject, JSONWriter.Options options, OutputStream out) throws IOException
      Writes a JSONObject out to the following output stream.
      Parameters:
      jsonObject - the object to write.
      options - the options to use for JSON output.
      out - the output stream to write to.
      Throws:
      IOException - if a write error occurs.
      Since:
      1.2.0
    • writeJSON

      public static void writeJSON(JSONObject jsonObject, JSONWriter.Options options, Writer writer) throws IOException
      Writes a JSONObject out to the following output stream.
      Parameters:
      jsonObject - the object to write.
      options - the options to use for JSON output.
      writer - the writer to write to.
      Throws:
      IOException - if a write error occurs.
      Since:
      1.2.0
    • writeJSONString

      public static String writeJSONString(JSONObject jsonObject, JSONWriter.Options options) throws IOException
      Writes a JSONObject out to the following output stream.
      Parameters:
      jsonObject - the object to write.
      options - the options to use for JSON output.
      Returns:
      the JSONObject as a JSON string.
      Throws:
      IOException - if a write error occurs.
      Since:
      1.2.0
    • writeJSON

      public static void writeJSON(JSONObject jsonObject, OutputStream out) throws IOException
      Writes a JSONObject out to the following output stream.
      Parameters:
      jsonObject - the object to write.
      out - the output stream to write to.
      Throws:
      IOException - if a write error occurs.
    • writeJSON

      public static void writeJSON(JSONObject jsonObject, Writer writer) throws IOException
      Writes a JSONObject out to the following output stream.
      Parameters:
      jsonObject - the object to write.
      writer - the writer to write to.
      Throws:
      IOException - if a write error occurs.
    • writeJSONString

      public static String writeJSONString(JSONObject jsonObject) throws IOException
      Writes a JSONObject out to the following output stream.
      Parameters:
      jsonObject - the object to write.
      Returns:
      the JSONObject as a JSON string.
      Throws:
      IOException - if a write error occurs.
    • writeJSON

      public static void writeJSON(Object object, JSONWriter.Options options, OutputStream out) throws IOException
      Writes a JSONObject out to the following output stream.
      Parameters:
      object - the object to write.
      options - the options to use for JSON output.
      out - the output stream to write to.
      Throws:
      IOException - if a write error occurs.
      Since:
      1.2.0
    • writeJSON

      public static void writeJSON(Object object, JSONWriter.Options options, Writer writer) throws IOException
      Writes a JSONObject out to the following output stream.
      Parameters:
      object - the object to write.
      options - the options to use for JSON output.
      writer - the writer to write to.
      Throws:
      IOException - if a write error occurs.
      Since:
      1.2.0
    • writeJSONString

      public static String writeJSONString(Object object, JSONWriter.Options options) throws IOException
      Writes a JSONObject out to the following output stream.
      Parameters:
      object - the object to write.
      options - the options to use for JSON output.
      Returns:
      the JSONObject as a JSON string.
      Throws:
      IOException - if a write error occurs.
      Since:
      1.2.0
    • writeJSON

      public static void writeJSON(Object object, OutputStream out) throws IOException
      Writes a JSONObject out to the following output stream.
      Parameters:
      object - the object to write.
      out - the output stream to write to.
      Throws:
      IOException - if a write error occurs.
    • writeJSON

      public static void writeJSON(Object object, Writer writer) throws IOException
      Writes a JSONObject out to the following output stream.
      Parameters:
      object - the object to write.
      writer - the writer to write to.
      Throws:
      IOException - if a write error occurs.
    • writeJSONString

      public static String writeJSONString(Object object) throws IOException
      Writes a JSONObject out to the following output stream.
      Parameters:
      object - the object to write.
      Returns:
      the JSONObject as a JSON string.
      Throws:
      IOException - if a write error occurs.
    • write

      public void write(JSONObject jsonObject, OutputStream out) throws IOException
      Writes a JSONObject out to the following output stream.
      Parameters:
      jsonObject - the object to write.
      out - the output stream to write to.
      Throws:
      IOException - if a write error occurs.
      Since:
      1.2.0
    • write

      public void write(JSONObject jsonObject, Writer writer) throws IOException
      Writes a JSONObject out to the following output stream.
      Parameters:
      jsonObject - the object to write.
      writer - the writer to write to.
      Throws:
      IOException - if a write error occurs.
      Since:
      1.2.0
    • writeString

      public String writeString(JSONObject jsonObject) throws IOException
      Writes a JSONObject out to the following output stream.
      Parameters:
      jsonObject - the object to write.
      Returns:
      the JSONObject as a JSON string.
      Throws:
      IOException - if a write error occurs.
      Since:
      1.2.0
    • write

      public void write(Object object, OutputStream out) throws IOException
      Writes a JSONObject out to the following output stream.
      Parameters:
      object - the object to write.
      out - the output stream to write to.
      Throws:
      IOException - if a write error occurs.
      Since:
      1.2.0
    • write

      public void write(Object object, Writer writer) throws IOException
      Writes a JSONObject out to the following output stream.
      Parameters:
      object - the object to write.
      writer - the writer to write to.
      Throws:
      IOException - if a write error occurs.
      Since:
      1.2.0
    • writeString

      public String writeString(Object object) throws IOException
      Writes a JSONObject out to the following output stream.
      Parameters:
      object - the object to write.
      Returns:
      the JSONObject as a JSON string.
      Throws:
      IOException - if a write error occurs.
      Since:
      1.2.0