api / tv.twelvetone.json / JsonValue / asInt

asInt

open fun asInt(): Int

Returns this JSON value as an int value, assuming that this value represents a JSON number that can be interpreted as Java int. If this is not the case, an exception is thrown.

To be interpreted as Java int, the JSON number must neither contain an exponent nor a fraction part. Moreover, the number must be in the Integer range.

Exceptions

UnsupportedOperationException - if this value is not a JSON number NumberFormatException - if this JSON number can not be interpreted as int value

Return
this value as int