kotlinx-serialization / kotlinx.serialization.json / JsonLiteral

JsonLiteral

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

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

isString indicates whether literal was explicitly constructed as a String and whether it should be serialized as one. E.g. JsonLiteral("42", false) and JsonLiteral("42", true) will be serialized as 42 and "42" respectively.

Constructors

(common, js, jvm, native)

<init>

Creates number literal

<init>(number: Number)

Creates boolean literal

<init>(boolean: Boolean)

Creates quoted string literal

<init>(string: String)

Properties

(common, js, jvm, native)

content

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

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

contentOrNull

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

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

isString

val isString: Boolean

Functions

(common, js, jvm, native)

equals

fun equals(other: Any?): Boolean
(common, js, jvm, native)

hashCode

fun hashCode(): Int
(common, js, jvm, native)

toString

fun toString(): String