Class JSONObject
-
- All Implemented Interfaces:
-
io.kjson.JSONStructure,io.kjson.JSONValue,kotlin.collections.Map
public final class JSONObject implements JSONStructure<String>, Map<String, JSONValue>
A JSON object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classJSONObject.BuilderJSONObject builder class.
public classJSONObject.Companion
-
Field Summary
Fields Modifier and Type Field Description private final Set<Entry.Map<String, JSONValue>>entriesprivate final Set<String>keysprivate final Collection<JSONValue>valuesprivate final JSONObjectasObjectprivate final JSONObjectasObjectOrNullprivate final Integersizepublic final static JSONObject.CompanionCompanion
-
Method Summary
Modifier and Type Method Description Set<Entry.Map<String, JSONValue>>getEntries()Set<String>getKeys()Collection<JSONValue>getValues()final JSONObjectgetAsObject()final JSONObjectgetAsObjectOrNull()IntegergetSize()The size of the structure. UnitappendTo(Appendable a)Append as a JSON string to an Appendable. StringtoJSON()Convert to a JSON string. Unitoutput(IntConsumer out)Output as a JSON string to an IntConsumer. UnitcoOutput(SuspendFunction1<Character, Unit> out)Output as a JSON string to a CoOutput. BooleanisEmpty()Return trueif the object is empty.BooleancontainsKey(String key)Return trueif the object contains the specified key (property name).BooleancontainsValue(JSONValue value)Return trueif the object contains the property value.JSONValueget(String key)Get the value for the property with the specified name, or nullif it is not present.final UnitforEachEntry(Function2<String, JSONValue, Unit> func)Perform a function with each property in turn (the function takes two parameters, the name String and value JSONValue ?).final UnitforEachKey(Function1<String, Unit> func)Perform a function with each property name in turn (the function takes a single parameters, the name String). final UnitforEachValue(Function1<JSONValue, Unit> func)Perform a function with each property value in turn (the function takes a single parameters, the value JSONValue ?).Booleanequals(Object other)Compare the object to another value, applying the rule in Java for comparing Maps.IntegerhashCode()Get the hash code for the object, applying the rule in Java for Maphash codes.StringtoString()Convert to a String (converts to JSON). -
Methods inherited from class io.kjson.JSONStructure
getArray, getBoolean, getByte, getDecimal, getInt, getLong, getObject, getShort, getString, getUByte, getUInt, getULong, getUShort, isNotEmpty -
Methods inherited from class kotlin.collections.Map
forEach, getOrDefault -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getEntries
Set<Entry.Map<String, JSONValue>> getEntries()
-
getValues
Collection<JSONValue> getValues()
-
getAsObject
final JSONObject getAsObject()
-
getAsObjectOrNull
final JSONObject getAsObjectOrNull()
-
appendTo
Unit appendTo(Appendable a)
Append as a JSON string to an Appendable.
-
output
Unit output(IntConsumer out)
Output as a JSON string to an IntConsumer.
-
coOutput
Unit coOutput(SuspendFunction1<Character, Unit> out)
Output as a JSON string to a CoOutput.
-
containsKey
Boolean containsKey(String key)
Return
trueif the object contains the specified key (property name).
-
containsValue
Boolean containsValue(JSONValue value)
Return
trueif the object contains the property value.
-
get
JSONValue get(String key)
Get the value for the property with the specified name, or
nullif it is not present.
-
forEachEntry
final Unit forEachEntry(Function2<String, JSONValue, Unit> func)
-
forEachKey
final Unit forEachKey(Function1<String, Unit> func)
Perform a function with each property name in turn (the function takes a single parameters, the name String).
-
forEachValue
final Unit forEachValue(Function1<JSONValue, Unit> func)
Perform a function with each property value in turn (the function takes a single parameters, the value JSONValue
?).
-
equals
Boolean equals(Object other)
Compare the object to another value, applying the rule in Java for comparing
Maps.
-
hashCode
Integer hashCode()
Get the hash code for the object, applying the rule in Java for
Maphash codes.
-
-
-
-