optPositiveInt

fun JSONObject.optPositiveInt(name: String, fallback: Int = -1, remove: Boolean = false): Int?

Returns the value mapped by name if it exists and is a positive integer or can be coerced to a positive integer, or fallback otherwise. If remove is true, then the mapping will be removed from the JSONObject.