Class JsonContent
- java.lang.Object
-
- org.apache.velocity.tools.generic.JsonContent
-
public class JsonContent extends java.lang.ObjectContainer for *either* an array *or* an object
-
-
Constructor Summary
Constructors Constructor Description JsonContent(org.json.simple.JsonArray array)wraps an arrayJsonContent(org.json.simple.JsonObject object)wraps an object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectget(int index)Get a value from root arrayjava.lang.Objectget(java.lang.String key)Get a property from root objectorg.json.simple.JsonArraygetArray()Gives acces to the wrapped JsonArray, if anyorg.json.simple.JsonObjectgetObject()Gives 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 JsonObjectjava.util.Iteratoriterator()Get an iterator.java.util.Iterator<java.lang.String>keys()Iterate keys of root object.java.util.Set<java.lang.String>keySet()Get set of root object keys.intsize()Get size of root object or array.java.lang.StringtoString()Convert JSON object or array into string
-
-
-
Method Detail
-
get
public java.lang.Object get(int index)
Get a value from root array- Parameters:
index- array index- Returns:
- value, or null
-
get
public java.lang.Object get(java.lang.String key)
Get a property from root object- Parameters:
key- map key- Returns:
- property value, or null
-
keys
public java.util.Iterator<java.lang.String> keys()
Iterate keys of root object.- Returns:
- iterator
-
keySet
public java.util.Set<java.lang.String> keySet()
Get set of root object keys.- Returns:
- keys set
-
iterator
public java.util.Iterator 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
public java.lang.String toString()
Convert JSON object or array into string- Overrides:
toStringin classjava.lang.Object- Returns:
- JSON representation of the root object or array
-
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
-
-