Class JsonContent


  • public class JsonContent
    extends java.lang.Object
    Container for *either* an array *or* an object
    • Constructor Summary

      Constructors 
      Constructor Description
      JsonContent​(org.json.simple.JsonArray array)
      wraps an array
      JsonContent​(org.json.simple.JsonObject object)
      wraps an object
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object get​(int index)
      Get a value from root array
      java.lang.Object get​(java.lang.String key)
      Get a property from root object
      org.json.simple.JsonArray getArray()
      Gives acces to the wrapped JsonArray, if any
      org.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
      java.util.Iterator iterator()
      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.
      int size()
      Get size of root object or array.
      java.lang.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​(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 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:
        toString in class java.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