JsonArray

表示 JSON 规范中的数组 ([])。

JsonArray 是一个 JsonElement 的有序集合,其行为类似于一个列表。 这是一个可变对象,可以在创建后自由地添加、修改或删除其元素。

Author

M8Test, [email protected], https://m8test.com

Functions

Link copied to clipboard
abstract fun addBoolean(value: Boolean)

向数组末尾添加一个 Boolean 值。

Link copied to clipboard
abstract fun addElement(element: JsonElement)

向数组末尾添加一个 JsonElement

Link copied to clipboard
abstract fun addNumber(value: Number)

向数组末尾添加一个 Number 值。

Link copied to clipboard
abstract fun addString(value: String)

向数组末尾添加一个 String 值。

Link copied to clipboard
abstract fun also(block: (ERROR CLASS: Symbol not found for com.google.gson.JsonElement) -> Unit): ObjectWrapper<ERROR CLASS: Symbol not found for com.google.gson.JsonElement>

对 ObjectWrapper 调用给定的 block 函数,并返回 ObjectWrapper 本身。

Link copied to clipboard
abstract fun apply(block: ERROR CLASS: Symbol not found for com.google.gson.JsonElement.() -> Unit): ObjectWrapper<ERROR CLASS: Symbol not found for com.google.gson.JsonElement>

对 ObjectWrapper 调用给定的 block 函数,并返回 ObjectWrapper 本身。

Link copied to clipboard
abstract operator fun get(index: Int): JsonElement

获取指定索引处的 JsonElement

Link copied to clipboard
abstract fun getBooleanOrNull(index: Int): Boolean?

安全地获取指定索引处的 Boolean 值。

Link copied to clipboard
abstract fun getDoubleOrNull(index: Int): Double?

安全地获取指定索引处的 Double 值。

Link copied to clipboard
abstract fun getElementOrNull(index: Int): JsonElement?

安全地获取指定索引处的 JsonElement

Link copied to clipboard
abstract fun getFloatOrNull(index: Int): Float?

安全地获取指定索引处的 Float 值。

Link copied to clipboard
abstract fun getIntOrNull(index: Int): Int?

安全地获取指定索引处的 Int 值。

Link copied to clipboard
abstract fun getJsonArrayOrNull(index: Int): JsonArray?

安全地获取指定索引处的 JsonArray

Link copied to clipboard
abstract fun getJsonObjectOrNull(index: Int): JsonObject?

安全地获取指定索引处的 JsonObject

Link copied to clipboard
abstract fun getLongOrNull(index: Int): Long?

安全地获取指定索引处的 Long 值。

Link copied to clipboard
abstract override fun getOrigin(): ERROR CLASS: Symbol not found for com.google.gson.JsonArray

获取原始的对象.

Link copied to clipboard
abstract fun getSize(): Int

获取数组中元素的数量。

Link copied to clipboard
abstract fun getStringOrNull(index: Int): String?

安全地获取指定索引处的 String 值。

Link copied to clipboard
abstract fun isEmpty(): Boolean

检查数组是否为空。

Link copied to clipboard
abstract fun isJsonArray(): Boolean

检查此元素是否为 JsonArray

Link copied to clipboard
abstract fun isJsonNull(): Boolean

检查此元素是否为 JSON null。

Link copied to clipboard
abstract fun isJsonObject(): Boolean

检查此元素是否为 JsonObject

Link copied to clipboard
abstract fun isJsonPrimitive(): Boolean

检查此元素是否为 JSON 原始类型 (string, number, boolean)。

Link copied to clipboard
abstract fun <R> let(block: (ERROR CLASS: Symbol not found for com.google.gson.JsonElement) -> R): ObjectWrapper<R>?

对 ObjectWrapper 调用给定的 block 函数,并返回 block 函数的结果包装在 ObjectWrapper 中。

Link copied to clipboard
abstract fun removeElement(index: Int): JsonElement

移除并返回指定索引处的元素。

Link copied to clipboard
abstract fun <R> run(block: ERROR CLASS: Symbol not found for com.google.gson.JsonElement.() -> R): ObjectWrapper<R>?

对 ObjectWrapper 调用给定的 block 函数,并返回 block 函数的结果包装在 ObjectWrapper 中。

Link copied to clipboard
abstract fun setElement(index: Int, element: JsonElement): JsonElement

在指定索引处设置一个 JsonElement

Link copied to clipboard
abstract fun setOrigin(origin: ERROR CLASS: Symbol not found for com.google.gson.JsonElement)

设置原始对象

Link copied to clipboard
abstract fun takeIf(predicate: (ERROR CLASS: Symbol not found for com.google.gson.JsonElement) -> Boolean): ObjectWrapper<ERROR CLASS: Symbol not found for com.google.gson.JsonElement>?

如果 ObjectWrapper 满足给定的 predicate,则返回 ObjectWrapper 本身,否则返回 null 包装在 ObjectWrapper? 中。

Link copied to clipboard
abstract fun takeUnless(predicate: (ERROR CLASS: Symbol not found for com.google.gson.JsonElement) -> Boolean): ObjectWrapper<ERROR CLASS: Symbol not found for com.google.gson.JsonElement>?

如果 ObjectWrapper 不满足给定的 predicate,则返回 ObjectWrapper 本身,否则返回 null 包装在 ObjectWrapper? 中。