Package com.cedarsoftware.io
Class JsonObject
java.lang.Object
com.cedarsoftware.io.JsonValue
com.cedarsoftware.io.JsonObject
- All Implemented Interfaces:
Serializable,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. - See Also:
-
Nested Class Summary
-
Field Summary
Fields inherited from class com.cedarsoftware.io.JsonValue
col, ENUM, id, ID, isFinished, ITEMS, KEYS, line, REF, refId, SHORT_ID, SHORT_ITEMS, SHORT_KEYS, SHORT_REF, SHORT_TYPE, target, TYPE, VALUE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleanObject[]getItems()Object[]getKeys()intDeprecated.Use size() instead.static intGets the current linear search threshold for JsonObject operations.Return the raw value provided for the@typefield, if any.getValue()inthashCode()booleanhasValue()booleanisArray()booleanbooleanisEmpty()booleanisMap()keySet()voidvoidstatic voidsetLinearSearchThreshold(int threshold) Sets the linear search threshold for JsonObject operations.voidintsize()toString()values()Methods inherited from class com.cedarsoftware.io.JsonValue
clearTypeResolutionCache, getCol, getId, getJavaType, getLine, getMaxTypeResolutionCacheSize, getRawType, getRawTypeName, getReferenceId, getTarget, getType, getTypeResolutionCacheSize, hasId, isFinished, isReference, setFinished, setFinishedTarget, setId, setJavaType, setMaxTypeResolutionCacheSize, setReferenceId, setTarget, setTypeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
JsonObject
public JsonObject()
-
-
Method Details
-
toString
-
isMap
public boolean isMap() -
isCollection
public boolean isCollection() -
isArray
public boolean isArray() -
getItems
-
setItems
-
getKeys
-
getTypeString
Return the raw value provided for the@typefield, if any.- Returns:
- String containing the raw type name or
nullif none was provided
-
size
public int size() -
getLength
Deprecated.Use size() instead. This method will be removed in a future release. -
setValue
-
getValue
-
hasValue
public boolean hasValue() -
hashCode
public int hashCode() -
equals
-
isEmpty
public boolean isEmpty() -
remove
-
put
-
putAll
-
clear
public void clear() -
containsKey
- Specified by:
containsKeyin interfaceMap<Object,Object>
-
containsValue
- Specified by:
containsValuein interfaceMap<Object,Object>
-
get
-
keySet
-
values
-
entrySet
-
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
-