Class JsonContent
java.lang.Object
org.apache.velocity.tools.generic.JsonContent
Container for *either* an array *or* an object
-
Constructor Summary
ConstructorsConstructorDescriptionJsonContent(org.json.simple.JsonArray array) wraps an arrayJsonContent(org.json.simple.JsonObject object) wraps an object -
Method Summary
Modifier and TypeMethodDescriptionget(int index) Get a value from root arrayGet a property from root objectorg.json.simple.JsonArraygetArray()Gives acces to the wrapped JsonArray, if anyorg.json.simple.JsonObjectGives access to the wrapped JsonObject, if anybooleanisArray()Check if wrapped object is a JsonArraybooleanisNull()Check if wrapped object is nullbooleanisObject()Check if wrapped object is a JsonObjectiterator()Get an iterator.keys()Iterate keys of root object.keySet()Get set of root object keys.intsize()Get size of root object or array.toString()Convert JSON object or array into string
-
Constructor Details
-
JsonContent
public JsonContent(org.json.simple.JsonObject object) wraps an object- Parameters:
object- JsonObject to wrap
-
JsonContent
public JsonContent(org.json.simple.JsonArray array) wraps an array- Parameters:
array- JsonArray to wrap
-
-
Method Details
-
get
Get a value from root array- Parameters:
index- array index- Returns:
- value, or null
-
get
-
keys
-
keySet
-
iterator
Get an iterator. For a root object, returns an iterator over key names. For a root array, returns an iterator over contained objects.- Returns:
- iterator
-
size
public int size()Get size of root object or array.- Returns:
- size
-
toString
-
isNull
public boolean isNull()Check if wrapped object is null- Returns:
- true if wrapped object is null
-
isObject
public boolean isObject()Check if wrapped object is a JsonObject- Returns:
- true if wrapped object is a JsonObject
-
isArray
public boolean isArray()Check if wrapped object is a JsonArray- Returns:
- true if wrapped object is a JsonArray
-
getObject
public org.json.simple.JsonObject getObject()Gives access to the wrapped JsonObject, if any- Returns:
- JsonObject or null
-
getArray
public org.json.simple.JsonArray getArray()Gives acces to the wrapped JsonArray, if any- Returns:
- JsonArray or null
-