Class JsonObject

java.lang.Object
com.cedarsoftware.io.JsonValue
com.cedarsoftware.io.JsonObject
All Implemented Interfaces:
Map<Object,Object>

public class JsonObject extends JsonValue implements Map<Object,Object>
This class holds a JSON object in a LinkedHashMap. LinkedHashMap used to keep fields in same order as they are when reflecting them in Java. Instances of this class hold a Map-of-Map representation of a Java object, read from the JSON input stream.
Author:
John DeRegnaucourt ([email protected])
Copyright (c) Cedar Software LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

License

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
  • Constructor Details

    • JsonObject

      public JsonObject()
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isMap

      public boolean isMap()
    • isCollection

      public boolean isCollection()
    • isArray

      public boolean isArray()
      Specified by:
      isArray in class JsonValue
    • getItems

      public Object[] getItems()
    • setItems

      public void setItems(Object[] array)
    • getKeys

      public Object[] getKeys()
    • getTypeString

      public String getTypeString()
      Return the raw value provided for the @type field, if any.
      Returns:
      String containing the raw type name or null if none was provided
    • size

      public int size()
      Specified by:
      size in interface Map<Object,Object>
    • getLength

      @Deprecated public int getLength()
      Deprecated.
      Use size() instead. This method will be removed in a future release.
    • setValue

      public void setValue(Object o)
    • getValue

      public Object getValue()
    • hasValue

      public boolean hasValue()
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map<Object,Object>
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Map<Object,Object>
      Overrides:
      equals in class Object
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<Object,Object>
    • remove

      public Object remove(Object key)
      Specified by:
      remove in interface Map<Object,Object>
    • put

      public Object put(Object key, Object value)
      Specified by:
      put in interface Map<Object,Object>
    • putAll

      public void putAll(Map<?,?> map)
      Specified by:
      putAll in interface Map<Object,Object>
    • clear

      public void clear()
      Specified by:
      clear in interface Map<Object,Object>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<Object,Object>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<Object,Object>
    • get

      public Object get(Object key)
      Specified by:
      get in interface Map<Object,Object>
    • keySet

      public Set<Object> keySet()
      Specified by:
      keySet in interface Map<Object,Object>
    • values

      public Collection<Object> values()
      Specified by:
      values in interface Map<Object,Object>
    • entrySet

      public Set<Map.Entry<Object,Object>> entrySet()
      Specified by:
      entrySet in interface Map<Object,Object>
    • setLinearSearchThreshold

      public static void setLinearSearchThreshold(int threshold)
      Sets the linear search threshold for JsonObject operations. This affects all JsonObject instances as the threshold is static.
      Parameters:
      threshold - int threshold for switching between linear and binary search. For arrays with size <= threshold, linear search is used for better cache locality. Must be at least 1.
      Throws:
      JsonIoException - if threshold is less than 1
    • getLinearSearchThreshold

      public static int getLinearSearchThreshold()
      Gets the current linear search threshold for JsonObject operations.
      Returns:
      int current linear search threshold