getValue

fun <T> JSONObject.getValue(key: String, defaultValue: T): T

Gets the value at key and gets casted to T, if could not be casted, or not existing returns defaultValue.

Author

Arnau Mora

Since

20220330

Parameters

key

The key to get.

defaultValue

The value to return if the object does not contain key or it's invalid.