public class JsonObj
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected NodeObj |
mNodeObj
The root node of the JSON tree.
|
Constructor and Description |
---|
JsonObj()
Creates an empty JSON object to be filled later by adding pairs.
|
JsonObj(java.lang.String str)
Parses the given string into a recursive JSON tree.
|
Modifier and Type | Method and Description |
---|---|
void |
addPair(java.lang.String string)
Adds a new pair where the value is null to the end of the node's
member list.
|
void |
addPair(java.lang.String string,
boolean value)
Adds a new pair where the value is a boolean to the end of the node's
member list.
|
void |
addPair(java.lang.String string,
double value)
Adds a new pair where the value is a number to the end of the node's
member list.
|
void |
addPair(java.lang.String string,
JsonObj value)
Adds a new pair where the value is another JsonObj to the end of the node's
member list.
|
void |
addPair(java.lang.String string,
NodeArray value)
Adds a new pair where the value is a NodeArray to the end of the node's
member list.
|
void |
addPair(java.lang.String string,
java.lang.String value)
Adds a new pair where the value is a string to the end of the node's
member list.
|
NodePair |
get(int idx)
Gets the pair with index idx of the JSON object.
|
java.lang.String |
getAsString()
Returns the JSON tree as formatted string.
|
NodePair |
getNext()
Gets the next pair in the JSON object.
|
NodeObj |
getNodeObj()
Returns the root node of the JSON tree.
|
NodeValue |
getValue(java.lang.String string)
Gets the value of the pair with the string (i. e. the label) given in the
parameter.
|
java.lang.String |
getValueAsString(java.lang.String string)
Gets the value of the pair with the string (i. e. the label) given in the
parameter and converts it to a string.
|
static void |
main(java.lang.String[] args) |
protected NodeObj mNodeObj
public JsonObj()
public JsonObj(java.lang.String str) throws ParseErrorEx
str
- the JSON object to parse as StringParseErrorEx
- Is thrown if the parser detects an error in the string.public NodeObj getNodeObj()
public java.lang.String getAsString()
public NodePair getNext()
public NodePair get(int idx)
idx
- index of the pair to retrievepublic java.lang.String getValueAsString(java.lang.String string)
string
- The label to search.public NodeValue getValue(java.lang.String string)
string
- The label to search.public void addPair(java.lang.String string, java.lang.String value)
string
- The pair's label.value
- The pair's value.public void addPair(java.lang.String string, double value)
string
- The pair's label.value
- The pair's value.public void addPair(java.lang.String string, boolean value)
string
- The pair's label.value
- The pair's value.public void addPair(java.lang.String string)
string
- The pair's label.public void addPair(java.lang.String string, NodeArray value)
string
- The pair's label.value
- The pair's value.public void addPair(java.lang.String string, JsonObj value)
string
- The pair's label.value
- The pair's value.public static void main(java.lang.String[] args)