Package jodd.json

Class JsonWriter

  • Direct Known Subclasses:
    JsonContext

    public class JsonWriter
    extends java.lang.Object
    Simple JSON writer.
    • Constructor Summary

      Constructors 
      Constructor Description
      JsonWriter​(java.lang.Appendable out, boolean strictStringEncoding)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isNamePopped()
      Returns true if pushName(String, boolean) pushed name} has been poped, i.e. used.
      protected void popName()
      Writes stored name to JSON string.
      void pushName​(java.lang.String name, boolean withComma)
      Stores name to temporary stack.
      protected void unicode​(char c)
      Writes unicode representation of a character.
      protected void write​(char c)
      Appends char to the buffer.
      void write​(java.lang.CharSequence charSequence)
      Appends char sequence to the buffer.
      void writeCloseArray()
      Writes close array sign.
      void writeCloseObject()
      Writes close object sign.
      void writeComma()
      Writes comma.
      void writeName​(java.lang.String name)
      Writes object's property name: string and a colon.
      void writeNumber​(java.lang.Number number)  
      void writeOpenArray()
      Writes open array sign.
      void writeOpenObject()
      Writes open object sign.
      void writeString​(java.lang.String value)
      Write a quoted and escaped value to the output.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • out

        protected final java.lang.Appendable out
      • strictStringEncoding

        protected final boolean strictStringEncoding
      • pushedName

        protected java.lang.String pushedName
      • pushedComma

        protected boolean pushedComma
      • isPushed

        protected boolean isPushed
    • Constructor Detail

      • JsonWriter

        public JsonWriter​(java.lang.Appendable out,
                          boolean strictStringEncoding)
    • Method Detail

      • pushName

        public void pushName​(java.lang.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.
      • writeOpenObject

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

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

        public void writeName​(java.lang.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​(java.lang.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​(java.lang.CharSequence charSequence)
        Appends char sequence to the buffer. Used for numbers, nulls, booleans, etc.
      • writeNumber

        public void writeNumber​(java.lang.Number number)
      • write

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