Package com.oss.asn1

Interface JSONWriter


public interface JSONWriter
This interface defines methods which are used to write JSON encodings to a target output stream. The methods are invoked by user-defined JSON encode() methods.
Since:
ASN.1/Java 8.0
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Writes the opening bracket representing the beginning of a JSON array.
    void
    Writes the opening curly bracket representing the beginning of a JSON object.
    void
    Writes the closing bracket representing the end of a JSON array.
    void
    Writes the closing curly bracket representing the end of a JSON object.
    void
    Writes the line separator unless the JsonWriter operates in the compact output mode.
    void
    write(byte[] b, int off, int len)
    Write the array of bytes.
    void
    write(int b)
    Write single octet.
    void
    Write a string doing UTF8 encoding.
    void
    writeChar(int character)
    Write a character doing UTF8 encoding.
    void
    Writes the key component of the key/value pair in the JSON object.
    void
    Writes JSON null token.
    void
    Writes the JSON number.
    void
    Writes the JSON string.
    void
    Writes JSON 'true' or 'false' token.
  • Method Details

    • write

      void write(int b) throws IOException
      Write single octet.
      Parameters:
      b - octet to write.
      Throws:
      IOException - is thrown if an error occurs when writing to a target stream
    • write

      void write(byte[] b, int off, int len) throws IOException
      Write the array of bytes.
      Parameters:
      b - byte array to write.
      off - starting offset in the byte array.
      len - the number of bytes to write.
      Throws:
      IOException - is thrown if an error occurs when writing to a target stream
    • write

      void write(String s) throws IOException, EncodeFailedException
      Write a string doing UTF8 encoding.
      Parameters:
      s - string to write.
      Throws:
      IOException - is thrown if an error occurs when writing to a target stream
      EncodeFailedException - is thrown if illegal character is detected
    • writeChar

      void writeChar(int character) throws IOException, EncodeFailedException
      Write a character doing UTF8 encoding.
      Parameters:
      character - a character to write.
      Throws:
      IOException - is thrown if an error occurs when writing to a target stream
      EncodeFailedException - is thrown if illegal character is detected
    • writeJsonNull

      void writeJsonNull() throws IOException
      Writes JSON null token.
      Throws:
      IOException - is thrown if an error occurs when writing to a target stream
    • writeJsonTrueOrFalse

      void writeJsonTrueOrFalse(boolean b) throws IOException
      Writes JSON 'true' or 'false' token.
      Parameters:
      b - boolean value
      Throws:
      IOException - if an I/O error occurs while the value is written.
    • writeJsonNumber

      void writeJsonNumber(String value) throws IOException
      Writes the JSON number. The caller is responsible to provide the 'value' that is the valid JSON number.
      Parameters:
      value - the number to write
      Throws:
      IOException - if an I/O error occurs while the value is written.
    • writeJsonString

      void writeJsonString(String value) throws IOException
      Writes the JSON string. The output is the 'value' surrounded in double quotes. If the 'value' contains control or special characters, they are automatically escaped.
      Parameters:
      value - the string value
      Throws:
      IOException - if an I/O error occurs while the value is written.
    • beginJsonObject

      void beginJsonObject() throws IOException
      Writes the opening curly bracket representing the beginning of a JSON object.
      Throws:
      IOException - if an I/O error occurs while the value is written.
    • endJsonObject

      void endJsonObject() throws IOException
      Writes the closing curly bracket representing the end of a JSON object.
      Throws:
      IOException - if an I/O error occurs while the value is written.
    • beginJsonArray

      void beginJsonArray() throws IOException
      Writes the opening bracket representing the beginning of a JSON array.
      Throws:
      IOException - if an I/O error occurs while the value is written.
    • endJsonArray

      void endJsonArray() throws IOException
      Writes the closing bracket representing the end of a JSON array.
      Throws:
      IOException - if an I/O error occurs while the value is written.
    • newline

      void newline() throws IOException
      Writes the line separator unless the JsonWriter operates in the compact output mode.
      Throws:
      IOException - if an I/O error occurs while the value is written.
    • writeJsonKey

      void writeJsonKey(String key) throws IOException
      Writes the key component of the key/value pair in the JSON object. The output is the key name surrounded in double quotes and followed by the colon. If the key name contains control or special characters, they are automatically escaped.
      Parameters:
      key - key name
      Throws:
      IOException - if an I/O error occurs while the value is written.