JsonPrimitiveAdapter

class JsonPrimitiveAdapter(val backing: JsonPrimitive) : JsonElementAdapter, KpaPrimitive(source)

Adapter exposing a JsonPrimitive (including JsonNull) as a KpaPrimitive.

Parameters

backing

The underlying JsonPrimitive.

Constructors

Link copied to clipboard
constructor(backing: JsonPrimitive)

Properties

Link copied to clipboard
open override val backing: JsonPrimitive
Link copied to clipboard
open override val booleanOrNull: Boolean?

The boolean value if isBoolean; null otherwise.

Link copied to clipboard
open override val doubleOrNull: Double?

The numeric value as Double if isNumber; null otherwise.

Link copied to clipboard
open override val isBoolean: Boolean

true if backing is a non-string whose content parses as a boolean ("true" or "false").

Link copied to clipboard
open override val isNull: Boolean

true if backing is JsonNull.

Link copied to clipboard
open override val isNumber: Boolean

true if backing is a non-string, non-boolean value whose content parses as a Double.

Link copied to clipboard
open override val isString: Boolean

true if backing was constructed with a string value.

Link copied to clipboard
open override val longOrNull: Long?

The numeric value as Long if isNumber and the content is integer-representable; null otherwise.

Link copied to clipboard
open override val stringOrNull: String?

The unquoted string content if isString; null otherwise.

Functions

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

Returns the unquoted string content for strings; the JSON-literal representation for all other types.

Link copied to clipboard
fun KpaElement.toJsonElement(): JsonElement

Returns the JsonElement backing this adapter, or throws if this is not a JsonElementAdapter.