optNullableString

fun JSONObject.optNullableString(name: String, remove: Boolean = false): String?

Returns the value mapped by name if it exists, or null if no such mapping exists, it is not a string or it is empty. If remove is true, then the mapping will be removed from the JSONObject.