Class JSONObject
-
- All Implemented Interfaces:
-
io.kjson.JSONStructure,io.kjson.JSONValue,kotlin.collections.Collection,kotlin.collections.Iterable,kotlin.collections.List,kotlin.collections.Map
public final class JSONObject implements JSONStructure<String>, Map<String, JSONValue>, List<JSONObject.Property>
A JSON object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classJSONObject.PropertyA class to represent a property (name-value pair).
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.JSONObject.Propertyget(Integer index)Get the Property at the nominated index. 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). Iterator<JSONObject.Property>iterator()Get an iterator over the object Propertys. ListIterator<JSONObject.Property>listIterator()Get a kotlin.collections.ListIterator over the object Propertys. ListIterator<JSONObject.Property>listIterator(Integer index)Get a kotlin.collections.ListIterator over the object Propertys, specifying the start index. JSONObjectsubList(Integer fromIndex, Integer toIndex)Get a JSONObjectcontaining the set of Propertys bounded byfromIndex(inclusive) andtoIndex(exclusive).IntegerlastIndexOf(JSONObject.Property element)Get the index of the last occurrence of the specified Property, or -1 if the Property is not found. Booleancontains(JSONObject.Property element)Return trueif the object contains the nominated Property.BooleancontainsAll(Collection<JSONObject.Property> elements)Return trueif the object contains all of the Propertys in another collection.IntegerindexOf(JSONObject.Property element)Get the index of the first occurrence of the specified Property, or -1 if the Property is not found. -
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 kotlin.collections.Iterable
forEach -
Methods inherited from class kotlin.collections.Collection
parallelStream, stream, toArray -
Methods inherited from class kotlin.collections.List
spliterator -
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.
-
get
JSONObject.Property get(Integer index)
Get the Property at the nominated index.
-
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.
-
iterator
Iterator<JSONObject.Property> iterator()
Get an iterator over the object Propertys.
-
listIterator
ListIterator<JSONObject.Property> listIterator()
Get a kotlin.collections.ListIterator over the object Propertys.
-
listIterator
ListIterator<JSONObject.Property> listIterator(Integer index)
Get a kotlin.collections.ListIterator over the object Propertys, specifying the start index.
-
subList
JSONObject subList(Integer fromIndex, Integer toIndex)
Get a
JSONObjectcontaining the set of Propertys bounded byfromIndex(inclusive) andtoIndex(exclusive).
-
lastIndexOf
Integer lastIndexOf(JSONObject.Property element)
-
contains
Boolean contains(JSONObject.Property element)
Return
trueif the object contains the nominated Property.
-
containsAll
Boolean containsAll(Collection<JSONObject.Property> elements)
Return
trueif the object contains all of the Propertys in another collection.
-
indexOf
Integer indexOf(JSONObject.Property element)
-
-
-
-