java.lang.Object
com.aquima.interactions.foundation.json.writer.JsonWriter
All Implemented Interfaces:
IJsonWriter

public class JsonWriter extends Object implements IJsonWriter
Class to write Json objects to a stream writer.
Since:
7.0
Author:
J. Gorter, Jon van Leuven
  • Constructor Details

    • JsonWriter

      public JsonWriter(Writer writer, boolean useIndentation)
      This construct a Json writer with a writer.
      Parameters:
      writer - The writer to write json result to.
      useIndentation - true to use whitespace indentation for pretty printing.
  • Method Details

    • close

      public void close() throws IOException
      Close this (and its internal) writer.
      Specified by:
      close in interface IJsonWriter
      Throws:
      IOException - If an I/O error occurs.
    • writeObjectStart

      public void writeObjectStart() throws IOException
      Begin appending an object.
      Specified by:
      writeObjectStart in interface IJsonWriter
      Throws:
      IOException - If an I/O error occurs.
    • writeObjectStart

      public void writeObjectStart(String memberName) throws IOException
      Begin appending an object with a name.
      Specified by:
      writeObjectStart in interface IJsonWriter
      Parameters:
      memberName - The member name, may not be null or empty.
      Throws:
      IOException - If an I/O error occurs.
    • writeObjectEnd

      public void writeObjectEnd() throws IOException
      End appending an object.
      Specified by:
      writeObjectEnd in interface IJsonWriter
      Throws:
      IOException - If an I/O error occurs.
    • writeMember

      public void writeMember(String memberName) throws IOException
      Appending a member.
      Specified by:
      writeMember in interface IJsonWriter
      Parameters:
      memberName - The member name, may not be null or empty.
      Throws:
      IOException - If an I/O error occurs.
    • writeMember

      public void writeMember(String memberName, long longValue) throws IOException
      Append a member with a long value.
      Specified by:
      writeMember in interface IJsonWriter
      Parameters:
      memberName - The member name, may not be null or empty.
      longValue - The value of the member.
      Throws:
      IOException - If an I/O error occurs.
    • writeMember

      public void writeMember(String memberName, double doubleValue) throws IOException
      Append a member with a double value.
      Specified by:
      writeMember in interface IJsonWriter
      Parameters:
      memberName - The member name, may not be null or empty.
      doubleValue - The value of the member.
      Throws:
      IOException - If an I/O error occurs.
    • writeMember

      public void writeMember(String memberName, boolean booleanValue) throws IOException
      Append a member with a boolean value.
      Specified by:
      writeMember in interface IJsonWriter
      Parameters:
      memberName - The member name, may not be null or empty.
      booleanValue - The value of the member.
      Throws:
      IOException - If an I/O error occurs.
    • writeMember

      public void writeMember(String memberName, String strValue) throws IOException
      Append a member with a string value.
      Specified by:
      writeMember in interface IJsonWriter
      Parameters:
      memberName - The member name, may not be null or empty.
      strValue - The value of the member.
      Throws:
      IOException - If an I/O error occurs.
    • writeNull

      public void writeNull(String memberName) throws IOException
      Append a member with a null value.
      Specified by:
      writeNull in interface IJsonWriter
      Parameters:
      memberName - The member name, may not be null or empty.
      Throws:
      IOException - If an I/O error occurs.
    • writeValue

      public void writeValue(long longValue) throws IOException
      Append a long value.
      Specified by:
      writeValue in interface IJsonWriter
      Parameters:
      longValue - The value.
      Throws:
      IOException - If an I/O error occurs.
    • writeValue

      public void writeValue(double doubleValue) throws IOException
      Append a double value.
      Specified by:
      writeValue in interface IJsonWriter
      Parameters:
      doubleValue - The value.
      Throws:
      IOException - If an I/O error occurs.
    • writeValue

      public void writeValue(boolean booleanValue) throws IOException
      Append a boolean value.
      Specified by:
      writeValue in interface IJsonWriter
      Parameters:
      booleanValue - The value.
      Throws:
      IOException - If an I/O error occurs.
    • writeValue

      public void writeValue(String strValue) throws IOException
      Append a string value.
      Specified by:
      writeValue in interface IJsonWriter
      Parameters:
      strValue - The value.
      Throws:
      IOException - If an I/O error occurs.
    • writeValueNull

      public void writeValueNull() throws IOException
      Append a null value.
      Specified by:
      writeValueNull in interface IJsonWriter
      Throws:
      IOException - If an I/O error occurs.
    • writeArrayStart

      public void writeArrayStart() throws IOException
      Begin appending an array.
      Specified by:
      writeArrayStart in interface IJsonWriter
      Throws:
      IOException - If an I/O error occurs.
    • writeArrayStart

      public void writeArrayStart(String memberName) throws IOException
      Begin appending an array with a name.
      Specified by:
      writeArrayStart in interface IJsonWriter
      Parameters:
      memberName - The member name, may not be null or empty.
      Throws:
      IOException - If an I/O error occurs.
    • writeArrayEnd

      public void writeArrayEnd() throws IOException
      End appending an array.
      Specified by:
      writeArrayEnd in interface IJsonWriter
      Throws:
      IOException - If an I/O error occurs.