intValue

fun JsonElement.intValue(vararg keys: String): Int

Navigates to the nested element at keys and returns its integer value. Extension function on JsonElement.


val JsonElement.intValue: Int

Returns the integer value of this JsonElement's primitive content. Extension property on JsonElement.

The content, quoted or not, must be a JSON integer (-?(0|[1-9][0-9]*)), so 007, +5 and non-ASCII digits are rejected on every platform, as isNumber and doubleValue reject them.

Throws

if this element is JSON null, not a primitive, or not an integer in range