public class JsopBuilder extends java.lang.Object implements JsopWriter
| Constructor and Description |
|---|
JsopBuilder() |
| Modifier and Type | Method and Description |
|---|---|
JsopBuilder |
append(JsopWriter buffer)
Append all entries of the given buffer.
|
JsopBuilder |
array()
Append '['.
|
static java.lang.String |
encode(java.lang.String s)
Convert a string to a quoted Json literal using the correct escape
sequences.
|
JsopBuilder |
encodedValue(java.lang.String value)
Append an already encoded value.
|
JsopBuilder |
endArray()
Append ']'.
|
JsopBuilder |
endObject()
Append '}'.
|
static void |
escape(java.lang.String s,
java.lang.StringBuilder buff)
Escape a string into the target buffer.
|
JsopBuilder |
key(java.lang.String name)
Append the key (in quotes) plus a colon.
|
int |
length()
Get the buffer length.
|
JsopBuilder |
newline()
Append a newline character.
|
JsopBuilder |
object()
Append '{'.
|
static java.lang.String |
prettyPrint(java.lang.String jsop)
Beautify (format) the json / jsop string.
|
void |
resetWriter()
Resets this instance.
|
void |
setLineLength(int length)
Set the line length, after which a newline is added (to improve
readability).
|
JsopBuilder |
tag(char tag)
Append a Jsop tag character.
|
java.lang.String |
toString()
Get the generated string.
|
JsopBuilder |
value(boolean value)
Append the boolean value 'true' or 'false'.
|
JsopBuilder |
value(long value)
Append a number.
|
JsopBuilder |
value(java.lang.String value)
Append a string or null.
|
public void resetWriter()
resetWriter in interface JsopWriterpublic void setLineLength(int length)
JsopWritersetLineLength in interface JsopWriterlength - the lengthpublic JsopBuilder append(JsopWriter buffer)
append in interface JsopWriterbuffer - the bufferpublic JsopBuilder tag(char tag)
tag in interface JsopWritertag - the string to appendpublic JsopBuilder newline()
newline in interface JsopWriterpublic JsopBuilder object()
object in interface JsopWriterpublic JsopBuilder endObject()
endObject in interface JsopWriterpublic JsopBuilder array()
array in interface JsopWriterpublic JsopBuilder endArray()
endArray in interface JsopWriterpublic JsopBuilder key(java.lang.String name)
key in interface JsopWritername - the keypublic JsopBuilder value(long value)
value in interface JsopWritervalue - the valuepublic JsopBuilder value(boolean value)
value in interface JsopWritervalue - the valuepublic JsopBuilder value(java.lang.String value)
value in interface JsopWritervalue - the valuepublic JsopBuilder encodedValue(java.lang.String value)
encodedValue in interface JsopWritervalue - the valuepublic java.lang.String toString()
toString in class java.lang.Objectpublic static java.lang.String encode(java.lang.String s)
escape(String, StringBuilder)). Null is encoded as "null"
(without quotes).s - the text to convertpublic static void escape(java.lang.String s,
java.lang.StringBuilder buff)
s - the string to escapebuff - the target bufferpublic int length()
public static java.lang.String prettyPrint(java.lang.String jsop)
jsop - the jsop stringCopyright © 2010 - 2023 Adobe. All Rights Reserved