Class JsonObject
java.lang.Object
jodd.json.JsonObject
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classIterator over values that handles maps and lists and wraps them in the JSON objects. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new, empty instance.JsonObject(Map<String, Object> map) Create an instance from a Map. -
Method Summary
Modifier and TypeMethodDescriptionclear()Removes all the entries in this JSON object.booleancontainsKey(String key) Returnstrueif the JSON object contain the specified key.(package private) static booleanelementEquals(Object o1, Object o2) booleanReturn the set of field names in the JSON objects.byte[]Returns the binary value with the specified key.byte[]LikegetBinary(String)but specifies a default value to return if there is no entry.getBoolean(String key) Returns the boolean value with the specified key.getBoolean(String key, Boolean def) LikegetBoolean(String)but specifies a default value to return if there is no entry.Returns the double value with the specified key.LikegetDouble(String)but specifies a default value to return if there is no entry.Returns the float value with the specified key.LikegetFloat(String)but specifies a default value to return if there is no entry.getInteger(String key) returns the integer value with the specified key.getInteger(String key, Integer def) LikegetInteger(String)but specifies a default value to return if there is no entry.getJsonArray(String key) Returns theJsonArrayvalue with the specified keygetJsonArray(String key, JsonArray def) LikegetJsonArray(String)but specifies a default value to return if there is no entry.getJsonObject(String key) Returns theJsonObjectvalue with the specified key.getJsonObject(String key, JsonObject def) LikegetJsonObject(String)but specifies a default value to return if there is no entry.Returns the long value with the specified key.LikegetLong(String)but specifies a default value to return if there is no entry.Returns the string value with the specified key.LikegetString(String)but specifies a default value to return if there is no entry.<T> TReturns the value with the specified key, as an object.<T> TLikegetValue(String)but specifies a default value to return if there is no entry.inthashCode()booleanisEmpty()Returnstrueif JSON object is empty.iterator()Returns an iterator of the entries in the JSON object.map()Returns the underlyingMapas is.mergeIn(JsonObject other) Merges in another JSON object.mergeIn(JsonObject other, int depth) Merges in another JSON object.mergeInDeep(JsonObject other) Merges in another JSON object.(package private) static booleanobjectEquals(Map<?, ?> m1, Object o2) Puts abyte[]into the JSON object with the specified key.Puts a boolean into the JSON object with the specified key.put(String key, CharSequence value) Puts anCharSequenceinto the JSON object with the specified key.Puts a double into the JSON object with the specified key.Puts an Enum into the JSON object with the specified key.Puts a float into the JSON object with the specified key.Puts an integer into the JSON object with the specified key.Puts a long into the JSON object with the specified key.Puts an object into the JSON object with the specified key.Puts a string into the JSON object with the specified key.Puts aJsonArrayinto the JSON object with the specified key.put(String key, JsonObject value) Puts another JSON object into the JSON object with the specified key.Puts anullvalue into the JSON object with the specified key.Removes an entry from this object.(package private) static ObjectresolveValue(Object value) intsize()Returns the number of entries in the JSON object.stream()Returns a stream of the entries in the JSON object.toString()Returns JSON serialized by defaultJsonSerializer.Methods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
map
-
-
Constructor Details
-
JsonObject
public JsonObject()Create a new, empty instance. -
JsonObject
-
-
Method Details
-
getString
-
getInteger
-
getLong
-
getDouble
-
getFloat
-
getBoolean
-
getJsonObject
Returns theJsonObjectvalue with the specified key. -
getJsonArray
-
getBinary
Returns the binary value with the specified key.JSON itself has no notion of a binary. This extension complies to the RFC-7493. THe byte array is Base64 encoded binary.
-
getValue
Returns the value with the specified key, as an object. -
getString
LikegetString(String)but specifies a default value to return if there is no entry. -
getInteger
LikegetInteger(String)but specifies a default value to return if there is no entry. -
getLong
LikegetLong(String)but specifies a default value to return if there is no entry. -
getDouble
LikegetDouble(String)but specifies a default value to return if there is no entry. -
getFloat
LikegetFloat(String)but specifies a default value to return if there is no entry. -
getBoolean
LikegetBoolean(String)but specifies a default value to return if there is no entry. -
getJsonObject
LikegetJsonObject(String)but specifies a default value to return if there is no entry. -
getJsonArray
LikegetJsonArray(String)but specifies a default value to return if there is no entry. -
getBinary
LikegetBinary(String)but specifies a default value to return if there is no entry. -
getValue
LikegetValue(String)but specifies a default value to return if there is no entry. -
containsKey
Returnstrueif the JSON object contain the specified key. -
fieldNames
-
put
Puts an Enum into the JSON object with the specified key.JSON has no concept of encoding Enums, so the Enum will be converted to a String using the
java.lang.Enum#namemethod and the value put as a String. -
put
Puts anCharSequenceinto the JSON object with the specified key. -
put
Puts a string into the JSON object with the specified key. -
put
Puts an integer into the JSON object with the specified key. -
put
Puts a long into the JSON object with the specified key. -
put
Puts a double into the JSON object with the specified key. -
put
Puts a float into the JSON object with the specified key. -
put
Puts a boolean into the JSON object with the specified key. -
putNull
Puts anullvalue into the JSON object with the specified key. -
put
Puts another JSON object into the JSON object with the specified key. -
put
Puts aJsonArrayinto the JSON object with the specified key. -
put
Puts abyte[]into the JSON object with the specified key.Follows JSON extension RFC7493, where binary will first be Base64 encoded before being put as a String.
-
put
Puts an object into the JSON object with the specified key. -
resolveValue
-
remove
-
mergeIn
Merges in another JSON object.This is the equivalent of putting all the entries of the other JSON object into this object. This is not a deep merge, entries containing (sub) JSON objects will be replaced entirely.
-
mergeInDeep
Merges in another JSON object. A deep merge (recursive) matches (sub) JSON objects in the existing tree and replaces all matching entries. JsonArrays are treated like any other entry, i.e. replaced entirely. -
mergeIn
Merges in another JSON object. The merge is deep (recursive) to the specified level. If depth is 0, no merge is performed, if depth is greater than the depth of one of the objects, a full deep merge is performed. -
map
-
stream
-
iterator
-
size
public int size()Returns the number of entries in the JSON object. -
clear
Removes all the entries in this JSON object. -
isEmpty
public boolean isEmpty()Returnstrueif JSON object is empty. -
toString
Returns JSON serialized by defaultJsonSerializer. -
equals
-
objectEquals
-
elementEquals
-
hashCode
-