Package snap.util

Class JSWriter

java.lang.Object
snap.util.JSWriter

public class JSWriter extends Object
Writes a JSON to string.
  • Constructor Details

    • JSWriter

      public JSWriter()
      Constructor.
  • Method Details

    • getIndent

      public String getIndent()
      Returns the current indent.
    • setIndent

      public JSWriter setIndent(String anIndent)
      Sets the current indent string.
    • isQuoteKeys

      public boolean isQuoteKeys()
      Returns whether to quote keys.
    • setQuoteKeys

      public void setQuoteKeys(boolean aValue)
      Sets whether to quote keys.
    • isCompacted

      public boolean isCompacted()
      Returns whether writer compacts JSON (no indent or newline).
    • setCompacted

      public void setCompacted(boolean aValue)
      Sets whether writer compacts JSON (no indent or newline).
    • getString

      public String getString(JSValue aNode)
      Returns a string for given JSON node.
    • getStringBuffer

      public StringBuffer getStringBuffer(JSValue aNode)
      Returns a string buffer for given JSON node.
    • append

      protected StringBuffer append(StringBuffer aSB, String aKey, JSValue aNode)
      Returns a string buffer for given JSON node.
    • appendJSObject

      protected StringBuffer appendJSObject(StringBuffer aSB, JSObject objectJS)
      Appends the given JSObject to StringBuffer.
    • appendJSArray

      protected StringBuffer appendJSArray(StringBuffer aSB, JSArray arrayJS)
      Appends the given JSArray to StringBuffer.
    • appendJSValue

      protected StringBuffer appendJSValue(StringBuffer aSB, JSValue valueJS)
      Appends the given JSValue to StringBuffer.
    • appendNewlineIndent

      protected StringBuffer appendNewlineIndent(StringBuffer aSB)
      Appends newline and indent.
    • appendNewlineIndent

      protected StringBuffer appendNewlineIndent(StringBuffer aSB, int aLevel)
      Appends newline and indent.
    • writeJSON

      public void writeJSON(JSValue aNode, String aPath)
      Writes the given JSON object to given file path.
    • isDeep

      protected boolean isDeep(JSValue aNode)
      Returns whether given node has child Map or List of Map/List.