AnyInt
Represents an integer number of type Int.
Serialization and deserialization
The serialization and deserialization processes of this type behave like for the Int type.
Here's an example of Kotlin code that encodes and decodes this type using the JavaScript Object Notation (JSON) format from kotlinx.serialization:
val number: AnyInt = 123.toNonZeroInt()
.getOrThrow()
val encoded: String = Json.encodeToString(number)
assertEquals(expected = "123", actual = encoded)
val decoded: AnyInt = Json.decodeFromString(encoded)
assertEquals(expected = number, actual = decoded)
Content copied to clipboard