[android-components](../index.md) / [mozilla.components.support.ktx.android.org.json](./index.md)

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

### Extensions for External Classes

| Name | Summary |
|---|---|
| [kotlin.collections.Map](kotlin.collections.-map/index.md) |  |

### Functions

| Name | Summary |
|---|---|
| [asSequence](as-sequence.md) | `fun <ERROR CLASS>.asSequence(): `[`Sequence`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/-sequence/index.html)`<`[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`>` |
| [getOrPutJSONObject](get-or-put-j-s-o-n-object.md) | `fun <ERROR CLASS>.getOrPutJSONObject(key: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, defaultValue: () -> <ERROR CLASS>): <ERROR CLASS>`<br>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](map-not-null.md) | `fun <T, R : `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`> <ERROR CLASS>.mapNotNull(getFromArray: <ERROR CLASS>.(index: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`) -> `[`T`](map-not-null.md#T)`, transform: (`[`T`](map-not-null.md#T)`) -> `[`R`](map-not-null.md#R)`?): `[`List`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)`<`[`R`](map-not-null.md#R)`>`<br>Returns a list containing only the non-null results of applying the given [transform](map-not-null.md#mozilla.components.support.ktx.android.org.json$mapNotNull(, kotlin.Function2((, kotlin.Int, mozilla.components.support.ktx.android.org.json.mapNotNull.T)), kotlin.Function1((mozilla.components.support.ktx.android.org.json.mapNotNull.T, mozilla.components.support.ktx.android.org.json.mapNotNull.R)))/transform) function to each element in the original collection as returned by [getFromArray](map-not-null.md#mozilla.components.support.ktx.android.org.json$mapNotNull(, kotlin.Function2((, kotlin.Int, mozilla.components.support.ktx.android.org.json.mapNotNull.T)), kotlin.Function1((mozilla.components.support.ktx.android.org.json.mapNotNull.T, mozilla.components.support.ktx.android.org.json.mapNotNull.R)))/getFromArray). If [getFromArray](map-not-null.md#mozilla.components.support.ktx.android.org.json$mapNotNull(, kotlin.Function2((, kotlin.Int, mozilla.components.support.ktx.android.org.json.mapNotNull.T)), kotlin.Function1((mozilla.components.support.ktx.android.org.json.mapNotNull.T, mozilla.components.support.ktx.android.org.json.mapNotNull.R)))/getFromArray) or [transform](map-not-null.md#mozilla.components.support.ktx.android.org.json$mapNotNull(, kotlin.Function2((, kotlin.Int, mozilla.components.support.ktx.android.org.json.mapNotNull.T)), kotlin.Function1((mozilla.components.support.ktx.android.org.json.mapNotNull.T, mozilla.components.support.ktx.android.org.json.mapNotNull.R)))/transform) throws a [JSONException](#), these elements will also be omitted. |
| [mergeWith](merge-with.md) | `fun <ERROR CLASS>.mergeWith(other: <ERROR CLASS>): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)<br>Merge the contents of another [JSONObject](#) with this object, overwriting the colliding keys. |
| [putIfNotNull](put-if-not-null.md) | `fun <ERROR CLASS>.putIfNotNull(key: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, value: `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`?): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)<br>Puts the specified value under the key if it's not null |
| [sortKeys](sort-keys.md) | `fun <ERROR CLASS>.sortKeys(): <ERROR CLASS>`<br>Sorts the keys of a JSONObject (and all of its child JSONObjects) alphabetically |
| [toList](to-list.md) | `fun <T> <ERROR CLASS>?.toList(): `[`List`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)`<`[`T`](to-list.md#T)`>`<br>Convenience method to convert a JSONArray into a List |
| [tryGetInt](try-get-int.md) | `fun <ERROR CLASS>.tryGetInt(key: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`): `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`?`<br>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](try-get-long.md) | `fun <ERROR CLASS>.tryGetLong(key: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`): `[`Long`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)`?`<br>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](try-get-string.md) | `fun <ERROR CLASS>.tryGetString(key: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`?`<br>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 |
