Interface JsopWriter

All Known Implementing Classes:
JsopBuilder, JsopStream

public interface JsopWriter
A builder for Json and Json diff strings. It knows when a comma is needed. A comma is appended before '{', '[', a value, or a key; but only if the last appended token was '}', ']', or a value. There is no limit to the number of nesting levels.
  • Method Details

    • array

      JsopWriter array()
      Append '['. A comma is appended first if needed.
      Returns:
      this
    • object

      JsopWriter object()
      Append '{'. A comma is appended first if needed.
      Returns:
      this
    • key

      JsopWriter key(String key)
      Append the key (in quotes) plus a colon. A comma is appended first if needed.
      Parameters:
      key - the key
      Returns:
      this
    • value

      JsopWriter value(String value)
      Append a string or null. A comma is appended first if needed.
      Parameters:
      value - the value
      Returns:
      this
    • encodedValue

      JsopWriter encodedValue(String raw)
      Append an already encoded value. A comma is appended first if needed.
      Parameters:
      raw - the value
      Returns:
      this
    • endObject

      JsopWriter endObject()
      Append '}'.
      Returns:
      this
    • endArray

      JsopWriter endArray()
      Append ']'.
      Returns:
      this
    • tag

      JsopWriter tag(char tag)
      Append a Jsop tag character.
      Parameters:
      tag - the string to append
      Returns:
      this
    • append

      JsopWriter append(JsopWriter diff)
      Append all entries of the given writer.
      Parameters:
      diff - the writer
      Returns:
      this
    • value

      JsopWriter value(long x)
      Append a number. A comma is appended first if needed.
      Parameters:
      x - the value
      Returns:
      this
    • value

      JsopWriter value(boolean b)
      Append the boolean value 'true' or 'false'. A comma is appended first if needed.
      Parameters:
      b - the value
      Returns:
      this
    • newline

      JsopWriter newline()
      Append a newline character.
      Returns:
      this
    • resetWriter

      void resetWriter()
      Resets this instance, so that all data is discarded.
    • setLineLength

      void setLineLength(int length)
      Set the line length, after which a newline is added (to improve readability).
      Parameters:
      length - the length