public class NavJson
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.util.ArrayList<java.lang.Object> |
allList
list to contain all the objects to be returned in a search of this NavJson object.
|
protected JSONObject |
jo
The JSONObject.
|
Constructor and Description |
---|
NavJson(JSONObject jsonObj)
Copy constructor.
|
NavJson(java.lang.String jsonString)
Constructor .
|
Modifier and Type | Method and Description |
---|---|
void |
fromJsonString(java.lang.String jsonString)
Set or reset the internal JSONObject from a JSON string.
|
java.lang.Object |
get(java.lang.String key)
Searches for the key in the stored JSONObject.
|
java.lang.Object[] |
getAll(java.lang.String key)
Searches for the key in the stored JSONArray.
|
protected java.lang.Object |
getFromJsonArray(JSONArray ja,
java.lang.String queryKey,
boolean getAll)
Gets the resuult of a search across an array of JSONObects.
|
protected java.lang.Object |
getFromJsonObject(JSONObject jobj,
java.lang.String queryKey,
boolean getAll)
Searches for a key within the json object and returns an Object containing the results.
|
static void |
main(java.lang.String[] args)
The main method.
|
java.lang.String |
toJsonString()
To json string.
|
java.lang.String |
toJsonString(int indentFactor)
To json string.
|
protected JSONObject jo
protected java.util.ArrayList<java.lang.Object> allList
public NavJson(java.lang.String jsonString)
jsonString
- - JSON string to ingestpublic NavJson(JSONObject jsonObj)
jsonObj
- the json objpublic void fromJsonString(java.lang.String jsonString)
jsonString
- the json object stringpublic java.lang.String toJsonString()
public java.lang.String toJsonString(int indentFactor)
indentFactor
- spaces to indent for pretty formattingprotected java.lang.Object getFromJsonObject(JSONObject jobj, java.lang.String queryKey, boolean getAll)
jobj
- the JSONObject to searchqueryKey
- the key value to search forgetAll
- a flag. If set to true, will return all the occurrences. Otherwise the first.protected java.lang.Object getFromJsonArray(JSONArray ja, java.lang.String queryKey, boolean getAll)
ja
- the JSONArray to searchqueryKey
- the key value to search forgetAll
- a flag. If set to true, will return all the occurances. Otherwise the first.public java.lang.Object get(java.lang.String key)
key
- the search keypublic java.lang.Object[] getAll(java.lang.String key)
key
- the keypublic static void main(java.lang.String[] args)
args
- the arguments