
commonMain.com.pubnub.api.JsonElement.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pubnub-kotlin-core-api Show documentation
Show all versions of pubnub-kotlin-core-api Show documentation
PubNub is a cross-platform client-to-client (1:1 and 1:many) push service in the cloud, capable of broadcasting real-time messages to millions of web and mobile clients simultaneously, in less than a quarter second!
The newest version!
package com.pubnub.api
expect abstract class JsonElement
expect fun JsonElement.isNull(): Boolean
expect fun JsonElement.asList(): List?
expect fun JsonElement.asLong(): Long?
expect fun JsonElement.asDouble(): Double?
expect fun JsonElement.asNumber(): Number?
expect fun JsonElement.asBoolean(): Boolean?
expect fun JsonElement.asString(): String?
expect fun JsonElement.asMap(): Map?
expect fun createJsonElement(any: Any?): JsonElement
fun JsonElement.decode(): Any? {
if (isNull()) {
return null
}
return asMap()?.mapValues { it.value.decode() }
?: asList()?.map { it.decode() }
?: asNumber()
?: asBoolean()
?: asString()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy