android-components / mozilla.components.support.ktx.android.org.json

Package mozilla.components.support.ktx.android.org.json

Extensions for External Classes

Name Summary
kotlin.collections.Iterable  
kotlin.collections.Map  

Functions

Name Summary
asSequence fun <V> <ERROR CLASS>.asSequence(getter: <ERROR CLASS>.(Int) -> V): Sequence<V>
Convenience method to convert a JSONArray into a sequence.fun <ERROR CLASS>.asSequence(): Sequence<Any>
getOrPutJSONObject fun <ERROR CLASS>.getOrPutJSONObject(key: String, defaultValue: () -> <ERROR CLASS>): <ERROR CLASS>
Gets the JSONObject value with the given key if it exists. Otherwise calls the defaultValue function, adds its result to the object, and returns that.
mapNotNull fun <T, R : Any> <ERROR CLASS>.mapNotNull(getFromArray: <ERROR CLASS>.(index: Int) -> T, transform: (T) -> R?): List<R>
Returns a list containing only the non-null results of applying the given transform function to each element in the original collection as returned by getFromArray. If getFromArray or transform throws a JSONException, these elements will also be omitted.
mergeWith fun <ERROR CLASS>.mergeWith(other: <ERROR CLASS>): Unit
Merge the contents of another JSONObject with this object, overwriting the colliding keys.
putIfNotNull fun <ERROR CLASS>.putIfNotNull(key: String, value: Any?): Unit
Puts the specified value under the key if it’s not null
sortKeys fun <ERROR CLASS>.sortKeys(): <ERROR CLASS>
Sorts the keys of a JSONObject (and all of its child JSONObjects) alphabetically
toList fun <T> <ERROR CLASS>?.toList(): List<T>
Convenience method to convert a JSONArray into a List
tryGet fun <ERROR CLASS>.tryGet(key: String): Any?
Returns the value mapped by {@code key} if it exists, and if the value returned is not null. If it’s null, it returns null
tryGetInt fun <ERROR CLASS>.tryGetInt(key: String): Int?
Returns the value mapped by {@code key} if it exists, and if the value returned is not null. If it’s null, it returns null
tryGetLong fun <ERROR CLASS>.tryGetLong(key: String): Long?
Returns the value mapped by {@code key} if it exists, and if the value returned is not null. If it’s null, it returns null
tryGetString fun <ERROR CLASS>.tryGetString(key: String): String?
Returns the value mapped by {@code key} if it exists, and if the value returned is not null. If it’s null, it returns null