JsonPrimitive

sealed class JsonPrimitive : JsonElement

Class representing JSON primitive value. JSON primitives include numbers, strings, booleans and special null value JsonNull.

Functions

Link copied to clipboard
open override fun toString(): String

Properties

Link copied to clipboard
abstract val content: String

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

Link copied to clipboard
abstract val isString: Boolean

Indicates whether the primitive was explicitly constructed from String and whether it should be serialized as one. E.g. JsonPrimitive("42") is represented by a string, while JsonPrimitive(42) is not. These primitives will be serialized as 42 and "42" respectively.

Inheritors

Link copied to clipboard

Extensions

Link copied to clipboard
val JsonPrimitive.boolean: Boolean

Returns content of current element as boolean

Link copied to clipboard
val JsonPrimitive.booleanOrNull: Boolean?

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

Link copied to clipboard
val JsonPrimitive.contentOrNull: String?

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

Link copied to clipboard
val JsonPrimitive.double: Double

Returns content of current element as double

Link copied to clipboard
val JsonPrimitive.doubleOrNull: Double?

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

Link copied to clipboard
val JsonPrimitive.float: Float

Returns content of current element as float

Link copied to clipboard
val JsonPrimitive.floatOrNull: Float?

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

Link copied to clipboard
val JsonPrimitive.int: Int

Returns content of the current element as int

Link copied to clipboard
val JsonPrimitive.intOrNull: Int?

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

Link copied to clipboard
val JsonPrimitive.long: Long

Returns content of current element as long

Link copied to clipboard
val JsonPrimitive.longOrNull: Long?

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