public class JSONBuilder
extends java.lang.Object
| Constructor and Description |
|---|
JSONBuilder() |
| Modifier and Type | Method and Description |
|---|---|
JSONBuilder |
beginArray()
Begins an anonymous array.
|
JSONBuilder |
beginArray(java.lang.String key) |
JSONBuilder |
beginFunction(java.lang.String name) |
JSONBuilder |
beginMap()
Begins an anonymous object.
|
JSONBuilder |
beginMap(java.lang.String key)
Begins a named object.
|
static JSONBuilder |
create()
Makes a new instance of JSONBuilder.
|
JSONBuilder |
endArray() |
JSONBuilder |
endFunction() |
JSONBuilder |
endMap()
Ends an object.
|
JSONBuilder |
entry(java.lang.String key,
boolean value)
Adds a boolean property to a map.
|
JSONBuilder |
entry(java.lang.String key,
double value)
Adds a double property to a map.
|
JSONBuilder |
entry(java.lang.String key,
float value)
Adds a float property to a map.
|
JSONBuilder |
entry(java.lang.String key,
int value)
Adds an int property to a map.
|
JSONBuilder |
entry(java.lang.String key,
java.util.List<java.lang.String> values,
boolean quote,
boolean escape)
Using the List of Strings, adds an array of strings as a names map property.
|
JSONBuilder |
entry(java.lang.String key,
long value)
Adds a long property to a map.
|
JSONBuilder |
entry(java.lang.String key,
java.lang.String value)
Adds a String property to a map.
|
JSONBuilder |
entry(java.lang.String key,
java.lang.String[] keyValuePairs)
Append a key bound String array that is itself a set of key-value pairs to a map.
|
JSONBuilder |
entry(java.lang.String key,
java.lang.String value,
boolean isStringLiteral)
Adds a String property as String literal optionally to a map.
|
JSONBuilder |
entryNonNullValue(java.lang.String key,
java.lang.Boolean value)
Adds a Boolean property to a map only if the value is non-null,
otherwise the key/value pair will not be added at all.
|
JSONBuilder |
entryNonNullValue(java.lang.String key,
java.lang.Double value)
Adds a Double property to a map only if the value is non-null,
otherwise the key/value pair will not be added at all.
|
JSONBuilder |
entryNonNullValue(java.lang.String key,
java.lang.Float value)
Adds a Float property to a map only if the value is non-null,
otherwise the key/value pair will not be added at all.
|
JSONBuilder |
entryNonNullValue(java.lang.String key,
java.lang.Integer value)
Adds an Integer property to a map only if the value is non-null,
otherwise the key/value pair will not be added at all.
|
JSONBuilder |
entryNonNullValue(java.lang.String key,
java.lang.Long value)
Adds a Long property to a map only if the value is non-null,
otherwise the key/value pair will not be added at all.
|
JSONBuilder |
entryNonNullValue(java.lang.String key,
java.lang.Object value)
Checks the Object to see if it's a primitive.
|
JSONBuilder |
entryNonNullValue(java.lang.String key,
java.lang.String value)
Adds a String property to a map only if the value is non-null,
otherwise the key/value pair will not be added at all.
|
static java.lang.String |
escapeString(java.lang.String value) |
JSONBuilder |
initialiseVar(java.lang.String varName) |
JSONBuilder |
initialiseWindowVar(java.lang.String varName) |
JSONBuilder |
item(boolean value)
Adds a boolean to an array or function call.
|
JSONBuilder |
item(double value)
Adds a double to an array or function call.
|
JSONBuilder |
item(float value)
Adds a float to an array or function call.
|
JSONBuilder |
item(int value)
Adds an int to an array or function call.
|
JSONBuilder |
item(long value)
Adds a long to an array or function call.
|
JSONBuilder |
item(java.lang.String value)
Adds an escaped String to an array or function call.
|
JSONBuilder |
item(java.lang.String value,
boolean escaped)
Adds a String to an array or function call.
|
java.lang.String |
toString()
Outputs the JSON string.
|
public static JSONBuilder create()
public JSONBuilder initialiseVar(java.lang.String varName)
public JSONBuilder initialiseWindowVar(java.lang.String varName)
public JSONBuilder beginMap()
public JSONBuilder beginMap(java.lang.String key)
key - name of the object.public JSONBuilder endMap()
public JSONBuilder beginArray()
public JSONBuilder beginArray(java.lang.String key)
public JSONBuilder endArray()
public JSONBuilder beginFunction(java.lang.String name)
public JSONBuilder endFunction()
public JSONBuilder entry(java.lang.String key, int value)
key - name of the property.value - value of the property.public JSONBuilder entry(java.lang.String key, long value)
key - name of the property.value - value of the property.public JSONBuilder entry(java.lang.String key, float value)
key - name of the property.value - value of the property.public JSONBuilder entry(java.lang.String key, double value)
key - name of the property.value - value of the property.public JSONBuilder entry(java.lang.String key, boolean value)
key - name of the property.value - value of the property.public JSONBuilder entry(java.lang.String key, java.lang.String[] keyValuePairs)
key - overall key to put entry underkeyValuePairs - Array of key value pair string entriespublic JSONBuilder entry(java.lang.String key, java.util.List<java.lang.String> values, boolean quote, boolean escape)
key - name of the property.values - strings to put into the arrayquote - whether to add quotes arround each stringescape - whether to escape each stringpublic JSONBuilder entryNonNullValue(java.lang.String key, java.lang.Integer value)
key - name of the property.value - value of the property.public JSONBuilder entryNonNullValue(java.lang.String key, java.lang.Long value)
key - name of the property.value - value of the property.public JSONBuilder entryNonNullValue(java.lang.String key, java.lang.Float value)
key - name of the property.value - value of the property.public JSONBuilder entryNonNullValue(java.lang.String key, java.lang.Double value)
key - name of the property.value - value of the property.public JSONBuilder entryNonNullValue(java.lang.String key, java.lang.Boolean value)
key - name of the property.value - value of the property.public JSONBuilder entryNonNullValue(java.lang.String key, java.lang.String value)
key - name of the property.value - value of the property.public JSONBuilder entryNonNullValue(java.lang.String key, java.lang.Object value)
key - value - public JSONBuilder entry(java.lang.String key, java.lang.String value)
key - name of the property.value - value of the property.public JSONBuilder entry(java.lang.String key, java.lang.String value, boolean isStringLiteral)
key - name of the property.value - value of the property.public JSONBuilder item(int value)
value - value of the item.public JSONBuilder item(long value)
value - value of the item.public JSONBuilder item(float value)
value - value of the item.public JSONBuilder item(double value)
value - value of the item.public JSONBuilder item(boolean value)
value - value of the item.public JSONBuilder item(java.lang.String value)
value - value of the item.public JSONBuilder item(java.lang.String value, boolean escaped)
value - value of the item.escaped - whether to escape the value and surround it with double quotes.public static java.lang.String escapeString(java.lang.String value)
public java.lang.String toString()
toString in class java.lang.ObjectCopyright 2014 ICEsoft Technologies Canada Corp., All Rights Reserved.