kotlinx-serialization / kotlinx.serialization.json / JsonPrimitive

JsonPrimitive

(common, js, jvm, native) sealed class JsonPrimitive : JsonElement

Class representing JSON primitive value. Can be either JsonLiteral or JsonNull.

Properties

(common, js, jvm, native)

boolean

Returns content of current element as boolean

val boolean: Boolean
(common, js, jvm, native)

booleanOrNull

Returns content of current element as boolean or null if current element is not a valid representation of boolean

val booleanOrNull: Boolean?
(common, js, jvm, native)

content

Content of given element without quotes. For JsonNull this methods returns null

abstract val content: String
(common, js, jvm, native)

contentOrNull

Content of the given element without quotes or null if current element is JsonNull

abstract val contentOrNull: String?
(common, js, jvm, native)

double

Returns content of current element as double

val double: Double
(common, js, jvm, native)

doubleOrNull

Returns content of current element as double or null if current element is not a valid representation of number

val doubleOrNull: Double?
(common, js, jvm, native)

float

Returns content of current element as float

val float: Float
(common, js, jvm, native)

floatOrNull

Returns content of current element as float or null if current element is not a valid representation of number

val floatOrNull: Float?
(common, js, jvm, native)

int

Returns content of current element as int

val int: Int
(common, js, jvm, native)

intOrNull

Returns content of current element as int or null if current element is not a valid representation of number

val intOrNull: Int?
(common, js, jvm, native)

long

Returns content of current element as long

val long: Long
(common, js, jvm, native)

longOrNull

Returns content of current element as long or null if current element is not a valid representation of number

val longOrNull: Long?
(common, js, jvm, native)

primitive

Convenience method to get current element as JsonPrimitive

val primitive: JsonPrimitive

Functions

(common, js, jvm, native)

toString

open fun toString(): String

Inheritors

(common, js, jvm, native)

JsonLiteral

Class representing JSON literals: numbers, booleans and string. Strings are always quoted.

class JsonLiteral : JsonPrimitive
(common, js, jvm, native)

JsonNull

Class representing JSON null value

object JsonNull : JsonPrimitive