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 JSONObjectasObjectprivate final JSONObjectasObjectOrNullprivate final Integersizeprivate final Set<Entry.Map<String, JSONValue>>entriesprivate final Set<String>keysprivate final Collection<JSONValue>valuespublic final static JSONObject.CompanionCompanion
-
Method Summary
Modifier and Type Method Description 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. UnitoutputTo(IntConsumer out)Output as a JSON string to an IntConsumer. Unitoutput(IntConsumer out)Output as a JSON string to an IntConsumer. UnitcoOutputTo(SuspendFunction1<Character, Unit> out)Output as a JSON string to a CoOutput. UnitcoOutput(SuspendFunction1<Character, Unit> out)Output as a JSON string to a CoOutput. BooleanisEmpty()Return trueif the object is empty.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, or the rule for comparingLists.IntegerhashCode()Get the hash code for the object, applying the rule in Java for Maphash codes.StringtoString()Convert to a String (converts to JSON). JSONObjectsubList(Integer fromIndex, Integer toIndex)Get a JSONObjectcontaining the set of Propertys bounded byfromIndex(inclusive) andtoIndex(exclusive).-
Methods inherited from class kotlin.collections.Map
containsKey, containsValue, forEach, getEntries, getKeys, getOrDefault, getValues -
Methods inherited from class kotlin.collections.List
contains, containsAll, get, indexOf, iterator, lastIndexOf, listIterator, listIterator, spliterator -
Methods inherited from class io.kjson.JSONStructure
get, getArray, getBoolean, getByte, getDecimal, getInt, getLong, getObject, getShort, getString, getUByte, getUInt, getULong, getUShort, isNotEmpty -
Methods inherited from class kotlin.collections.Iterable
forEach -
Methods inherited from class kotlin.collections.Collection
parallelStream, stream, toArray -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getAsObject
final JSONObject getAsObject()
-
getAsObjectOrNull
final JSONObject getAsObjectOrNull()
-
appendTo
Unit appendTo(Appendable a)
Append as a JSON string to an Appendable.
-
outputTo
Unit outputTo(IntConsumer out)
Output as a JSON string to an IntConsumer.
-
output
@Deprecated(message = "renamed to outputTo", replaceWith = @ReplaceWith(imports = {}, expression = "outputTo(out)")) Unit output(IntConsumer out)
Output as a JSON string to an IntConsumer.
-
coOutputTo
Unit coOutputTo(SuspendFunction1<Character, Unit> out)
Output as a JSON string to a CoOutput.
-
coOutput
@Deprecated(message = "renamed to coOutputTo", replaceWith = @ReplaceWith(imports = {}, expression = "coOutputTo(out)")) Unit coOutput(SuspendFunction1<Character, Unit> out)
Output as a JSON string to a CoOutput.
-
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, or the rule for comparingLists.
-
hashCode
Integer hashCode()
Get the hash code for the object, applying the rule in Java for
Maphash codes. Note that the Java rule forListhash codes is different, so it will not be possible to use this class in a hashing context (e.g. in aHashSet) with otherListimplementations.
-
subList
JSONObject subList(Integer fromIndex, Integer toIndex)
Get a
JSONObjectcontaining the set of Propertys bounded byfromIndex(inclusive) andtoIndex(exclusive).
-
-
-
-