optional

inline fun <T> <Error class: unknown class>.optional(key: String, default: () -> T? = { null }): T?

Gets an object from a JSONObject by key, returning default (null if not specified) if the key is not found.

Usage:

jsonObj.optional<String>("key")
jsonObj.options<String>("key") { "default" }

Since

0.46.0