Documentation for maplib/Json.kt

class JsonDocument

Json document class.

fun constructor(handle: Long = API.jsonDocumentCreateInt())

Main constructor

Параметры
  • handle – e C API handle.

val handle : Long = API.jsonDocumentCreateInt()

e C API handle.

fun load(url: String, options: Map<String, String> = mapOf(), callback: ((status: StatusCode, complete: Double, message: String) -> Boolean)? = null) : Boolean

Load document from url.

Параметры
  • url – Url to fetch Json document.

  • options – Options passed to the http request function. See Request.get for details.

  • callback – Callback function to show progress or cancel operation.

Результат

True on success.

fun getRoot() : JsonObject

Get json document root object.

Результат

JsonObject class instance.

class JsonObject

JsonObject class.

fun constructor(handle: Long = 0)

Main constructor

Параметры
  • handle – e C API handle. For new objects is 0.

val handle : Long = 0

e C API handle. For new objects is 0.

val valid : Boolean

If json object valid the property will be true. The property is readonly.

val name : String

Json object name.

val type : JsonObjectType

Json object type.

fun getString(defaultValue: String) : String

Get string from json object.

Параметры
  • defaultValue – Default string value.

Результат

string

fun getDouble(defaultValue: Double) : Double

Get double from json object.

Параметры
  • defaultValue – Default double value.

Результат

double

fun getInteger(defaultValue: Int) : Int

Get int from json object.

Параметры
  • defaultValue – Default int value.

Результат

integer

fun getLong(defaultValue: Long) : Long

Get long from json object.

Параметры
  • defaultValue – Default long value.

Результат

long

fun getBool(defaultValue: Boolean) : Boolean

Get bool from json object.

Параметры
  • defaultValue – Default bool value.

Результат

boolean

fun getObject(name: String) : JsonObject

Get json object from json object.

Параметры
  • name – Key name.

Результат

json object.

fun getString(key: String, defaultValue: String) : String

Get string from json object.

Параметры
  • key – Key value.

  • defaultValue – Default value.

Результат

String value.

fun getDouble(key: String, defaultValue: Double) : Double

Get double from json object.

Параметры
  • key – Key value.

  • defaultValue – Default value.

Результат

Double value.

fun getInteger(key: String, defaultValue: Int) : Int

Get integer from json object.

Параметры
  • key – Key value.

  • defaultValue – Default value.

Результат

Integer value.

fun getLong(key: String, defaultValue: Long) : Long

Get long from json object.

Параметры
  • key – Key value.

  • defaultValue – Default value.

Результат

Long value.

fun getBool(key: String, defaultValue: Boolean) : Boolean

Get bool from json object.

Параметры
  • key – Key value.

  • defaultValue – Default value.

Результат

Boolean value.

fun setString(key: String, value: String) : Boolean

Set string value.

Параметры
  • value – Value to set.

  • key – Key value.

Результат

True on success.

fun setDouble(key: String, value: Double) : Boolean

Set double value.

Параметры
  • value – Value to set.

  • key – Key value.

Результат

True on success.

fun setInteger(key: String, value: Int) : Boolean

Set integer value.

Параметры
  • value – Value to set.

  • key – Key value.

Результат

True on success.

fun setLong(key: String, value: Long) : Boolean

Set long value.

Параметры
  • value – Value to set.

  • key – Key value.

Результат

True on success.

fun setBoolean(key: String, value: Boolean) : Boolean

Set boolean value.

Параметры
  • value – Value to set.

  • key – Key value.

Результат

True on success.

fun children() : Array<JsonObject>

Get json object children.

Результат

Array of children.

fun getArray(name: String) : JsonArray

Get array by name.

Параметры
  • name – Array object name.

Результат

Json array object.

enum class JsonObjectType

Json object type.

  • NULL = 1 : Null object.

  • OBJECT = 2 : Another object.

  • ARRAY = 3 : Array of json objects.

  • BOOLEAN = 4 : Boolean object.

  • STRING = 5 : String object.

  • INTEGER = 6 : Integer object.

  • LONG = 7 : Long object.

  • DOUBLE = 8 : Double object.

class JsonArray

Json array class.

constructor(handle Long )

Main constructor

val size : Int

Item count.

fun getItem(index: Int) : JsonObject

Get item by index. Index mast be between 0 and size.

Параметры
  • index – Item index.

Результат

Json object.