Package snap.util
Class JSWriter
java.lang.Object
snap.util.JSWriter
Writes a JSON to string.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected StringBuffer
append
(StringBuffer aSB, String aKey, JSValue aNode) Returns a string buffer for given JSON node.protected StringBuffer
appendJSArray
(StringBuffer aSB, JSArray arrayJS) Appends the given JSArray to StringBuffer.protected StringBuffer
appendJSObject
(StringBuffer aSB, JSObject objectJS) Appends the given JSObject to StringBuffer.protected StringBuffer
appendJSValue
(StringBuffer aSB, JSValue valueJS) Appends the given JSValue to StringBuffer.protected StringBuffer
Appends newline and indent.protected StringBuffer
appendNewlineIndent
(StringBuffer aSB, int aLevel) Appends newline and indent.Returns the current indent.Returns a string for given JSON node.getStringBuffer
(JSValue aNode) Returns a string buffer for given JSON node.boolean
Returns whether writer compacts JSON (no indent or newline).protected boolean
Returns whether given node has child Map or List of Map/List.boolean
Returns whether to quote keys.void
setCompacted
(boolean aValue) Sets whether writer compacts JSON (no indent or newline).Sets the current indent string.void
setQuoteKeys
(boolean aValue) Sets whether to quote keys.void
Writes the given JSON object to given file path.
-
Constructor Details
-
JSWriter
public JSWriter()Constructor.
-
-
Method Details
-
getIndent
Returns the current indent. -
setIndent
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
Returns a string for given JSON node. -
getStringBuffer
Returns a string buffer for given JSON node. -
append
Returns a string buffer for given JSON node. -
appendJSObject
Appends the given JSObject to StringBuffer. -
appendJSArray
Appends the given JSArray to StringBuffer. -
appendJSValue
Appends the given JSValue to StringBuffer. -
appendNewlineIndent
Appends newline and indent. -
appendNewlineIndent
Appends newline and indent. -
writeJSON
Writes the given JSON object to given file path. -
isDeep
Returns whether given node has child Map or List of Map/List.
-