Interface JsonGenerator

All Superinterfaces:
AutoCloseable, Closeable

public interface JsonGenerator extends Closeable
Abstracts Jacksons JsonGenerator for more fine-grained, incremental creation of JSON.
Author:
Holger Eichelberger, SSE
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    writeArray(double[] array, int offset, int length)
    Value write method that can be called to write a single array.
    void
    writeArray(int[] array, int offset, int length)
    Value write method that can be called to write a single array.
    void
    writeArray(long[] array, int offset, int length)
    Value write method that can be called to write a single array.
    void
    writeArray(String[] array, int offset, int length)
    Value write method that can be called to write a single array.
    void
    writeBoolean(boolean value)
    Method for outputting literal JSON boolean value (one of Strings 'true' and 'false').
    void
    Method for writing closing marker of a JSON Array value.
    void
    Method for writing closing marker of an Object value.
    void
    Method for writing a field name.
    void
    Method for outputting literal JSON null value.
    void
    writeNumber(double number)
    Method for outputting indicate JSON numeric value.
    void
    writeNumber(float number)
    Method for outputting indicate JSON numeric value.
    void
    writeNumber(int number)
    Method for outputting given value as JSON number.
    void
    writeNumber(long number)
    Method for outputting given value as JSON number.
    void
    writeNumber(short number)
    Method for outputting given value as JSON number.
    void
    Method for outputting indicate JSON numeric value.
    void
    Method for outputting given value as JSON number.
    void
    Method for writing given Java object (POJO) as Json.
    void
    Method for writing starting marker of a Array value.
    void
    Method for writing starting marker of an Object value.
    void
    Method for outputting a String value.

    Methods inherited from interface java.io.Closeable

    close
  • Method Details

    • writeNumber

      void writeNumber(short number) throws IOException
      Method for outputting given value as JSON number. Can be called in any context where a value is expected (Array value, Object field value, root-level value).
      Parameters:
      number - value to write
      Throws:
      IOException - when the number cannot be written
    • writeNumber

      void writeNumber(int number) throws IOException
      Method for outputting given value as JSON number. Can be called in any context where a value is expected (Array value, Object field value, root-level value).
      Parameters:
      number - value to write
      Throws:
      IOException - when the number cannot be written
    • writeNumber

      void writeNumber(long number) throws IOException
      Method for outputting given value as JSON number. Can be called in any context where a value is expected (Array value, Object field value, root-level value).
      Parameters:
      number - value to write
      Throws:
      IOException - when the number cannot be written
    • writeNumber

      void writeNumber(BigInteger number) throws IOException
      Method for outputting given value as JSON number. Can be called in any context where a value is expected (Array value, Object field value, root-level value).
      Parameters:
      number - value to write
      Throws:
      IOException - when the number cannot be written
    • writeNumber

      void writeNumber(double number) throws IOException
      Method for outputting indicate JSON numeric value. Can be called in any context where a value is expected (Array value, Object field value, root-level value).
      Parameters:
      number - value to write
      Throws:
      IOException - when the number cannot be written
    • writeNumber

      void writeNumber(float number) throws IOException
      Method for outputting indicate JSON numeric value. Can be called in any context where a value is expected (Array value, Object field value, root-level value).
      Parameters:
      number - value to write
      Throws:
      IOException - when the number cannot be written
    • writeNumber

      void writeNumber(BigDecimal number) throws IOException
      Method for outputting indicate JSON numeric value. Can be called in any context where a value is expected (Array value, Object field value, root-level value).
      Parameters:
      number - value to write
      Throws:
      IOException - when the number cannot be written
    • writeString

      void writeString(String text) throws IOException
      Method for outputting a String value. Depending on context this means either array element, (object) field value or a stand alone String; but in all cases, String will be surrounded in double quotes, and contents will be properly escaped as required by JSON specification.
      Parameters:
      text - value to write
      Throws:
      IOException - when the text cannot be written
    • writeBoolean

      void writeBoolean(boolean value) throws IOException
      Method for outputting literal JSON boolean value (one of Strings 'true' and 'false'). Can be called in any context where a value is expected (Array value, Object field value, root-level value).
      Parameters:
      value - the value to write
      Throws:
      IOException - when the value cannot be written
    • writeNull

      void writeNull() throws IOException
      Method for outputting literal JSON null value. Can be called in any context where a value is expected (Array value, Object field value, root-level value).
      Throws:
      IOException - when the value cannot be written
    • writeArray

      void writeArray(int[] array, int offset, int length) throws IOException
      Value write method that can be called to write a single array.
      Parameters:
      array - Array that contains values to write
      offset - Offset of the first element to write, within array
      length - Number of elements in array to write, from `offset` to `offset + len - 1`
      Throws:
      IOException - when the array cannot be written
    • writeArray

      void writeArray(long[] array, int offset, int length) throws IOException
      Value write method that can be called to write a single array.
      Parameters:
      array - Array that contains values to write
      offset - Offset of the first element to write, within array
      length - Number of elements in array to write, from `offset` to `offset + len - 1`
      Throws:
      IOException - when the array cannot be written
      Since:
      2.8
    • writeArray

      void writeArray(double[] array, int offset, int length) throws IOException
      Value write method that can be called to write a single array.
      Parameters:
      array - Array that contains values to write
      offset - Offset of the first element to write, within array
      length - Number of elements in array to write, from `offset` to `offset + len - 1`
      Throws:
      IOException - when the array cannot be written
    • writeArray

      void writeArray(String[] array, int offset, int length) throws IOException
      Value write method that can be called to write a single array.
      Parameters:
      array - Array that contains values to write
      offset - Offset of the first element to write, within array
      length - Number of elements in array to write, from `offset` to `offset + len - 1`
      Throws:
      IOException - when the array cannot be written
    • writeStartArray

      void writeStartArray() throws IOException
      Method for writing starting marker of a Array value. Array values can be written in any context where values are allowed: meaning everywhere except for when a field name is expected.
      Throws:
      IOException - when the array cannot be written
    • writeEndArray

      void writeEndArray() throws IOException
      Method for writing closing marker of a JSON Array value. Marker can be written if the innermost structured type is Array.
      Throws:
      IOException - when the array cannot be written
    • writeStartObject

      void writeStartObject() throws IOException
      Method for writing starting marker of an Object value. Object values can be written in any context where values are allowed: meaning everywhere except for when a field name is expected.
      Throws:
      IOException - when the object cannot be written
    • writeEndObject

      void writeEndObject() throws IOException
      Method for writing closing marker of an Object value. Marker can be written if the innermost structured type is Object, and the last written event was either a complete value, or a start object.
      Throws:
      IOException - when the object cannot be written
    • writeFieldName

      void writeFieldName(String name) throws IOException
      Method for writing a field name. Field names can only be written in Object context , when field name is expected (field names alternate with values).
      Throws:
      IOException - when the name cannot be written
    • writeObject

      void writeObject(Object pojo) throws IOException
      Method for writing given Java object (POJO) as Json.
      Throws:
      IOException - when the object cannot be written