org.apache.velocity.tools.generic

## Class JsonContent

- java.lang.Object
- - org.apache.velocity.tools.generic.JsonContent

    public class JsonContent
    extends Object

Container for *either* an array *or* an object

### Constructor Summary

Constructors
Constructor and Description
`JsonContent(com.github.cliftonlabs.json_simple.JsonArray array)` wraps an array
`JsonContent(com.github.cliftonlabs.json_simple.JsonObject object)` wraps an object

### Method Summary

All Methods Instance Methods Concrete Methods
`Object` `get(int index)` Get a value from root array
`Object` `get(String key)` Get a property from root object
`com.github.cliftonlabs.json_simple.JsonArray` `getArray()` Gives acces to the wrapped JsonArray, if any
`com.github.cliftonlabs.json_simple.JsonObject` `getObject()` Gives access to the wrapped JsonObject, if any
`boolean` `isArray()` Check if wrapped object is a JsonArray
`boolean` `isNull()` Check if wrapped object is null
`boolean` `isObject()` Check if wrapped object is a JsonObject
`Iterator` `iterator()` Get an iterator.
`Iterator<String>` `keys()` Iterate keys of root object.
`Set<String>` `keySet()` Get set of root object keys.
`int` `size()` Get size of root object or array.
`String` `toString()` Convert JSON object or array into string

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### JsonContent

    public JsonContent(com.github.cliftonlabs.json_simple.JsonObject object)

wraps an object

Parameters:
  `object` - JsonObject to wrap

#### JsonContent

    public JsonContent(com.github.cliftonlabs.json_simple.JsonArray array)

wraps an array

Parameters:
  `array` - JsonArray to wrap

### Method Detail

#### get

    public Object get(int index)

Get a value from root array

Parameters:
  `index` - array index
Returns:
  value, or null

#### get

    public Object get(String key)

Get a property from root object

Parameters:
  `key` - map key
Returns:
  property value, or null

#### keys

    public Iterator<String> keys()

Iterate keys of root object.

Returns:
  iterator

#### keySet

    public Set<String> keySet()

Get set of root object keys.

Returns:
  keys set

#### iterator

    public 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 String toString()

Convert JSON object or array into string

Overrides:
  `toString` in class `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 com.github.cliftonlabs.json_simple.JsonObject getObject()

Gives access to the wrapped JsonObject, if any

Returns:
  JsonObject or null

#### getArray

    public com.github.cliftonlabs.json_simple.JsonArray getArray()

Gives acces to the wrapped JsonArray, if any

Returns:
  JsonArray or null