Package jodd.json

Class JsonWriter

java.lang.Object
jodd.json.JsonWriter
Direct Known Subclasses:
JsonContext

public class JsonWriter extends Object
Simple JSON writer.
  • Field Details

    • out

      protected final Appendable out
    • strictStringEncoding

      protected final boolean strictStringEncoding
    • pushedName

      protected String pushedName
    • pushedComma

      protected boolean pushedComma
    • isPushed

      protected boolean isPushed
  • Constructor Details

    • JsonWriter

      public JsonWriter(Appendable out, boolean strictStringEncoding)
  • Method Details

    • pushName

      public void pushName(String name, boolean withComma)
      Stores name to temporary stack. Used when name's value may or may not be serialized (e.g. it may be excluded), in that case we do not need to write the name.
    • popName

      protected void popName()
      Writes stored name to JSON string. Cleans storage.
    • isNamePopped

      public boolean isNamePopped()
      Returns true if pushName(String, boolean) pushed name} has been poped, i.e. used.
    • writeOpenObject

      public void writeOpenObject()
      Writes open object sign.
    • writeCloseObject

      public void writeCloseObject()
      Writes close object sign.
    • writeName

      public void writeName(String name)
      Writes object's property name: string and a colon.
    • writeOpenArray

      public void writeOpenArray()
      Writes open array sign.
    • writeCloseArray

      public void writeCloseArray()
      Writes close array sign.
    • writeString

      public void writeString(String value)
      Write a quoted and escaped value to the output.
    • unicode

      protected void unicode(char c)
      Writes unicode representation of a character.
    • writeComma

      public void writeComma()
      Writes comma.
    • write

      public void write(CharSequence charSequence)
      Appends char sequence to the buffer. Used for numbers, nulls, booleans, etc.
    • writeNumber

      public void writeNumber(Number number)
    • write

      protected void write(char c)
      Appends char to the buffer. Used internally.