json
Generated by tinox doc
tinox.core.json, split out of the bundled stdlib as a standalone tinox-central package.
Parse and read
import tinox.core.json
class Main
{
fnc main() -> Int32
{
const value: JsonValue = Json::parse("{\"name\": \"tinox\", \"stable\": true}")
println(value.getField("name").getString())
println(value.getField("stable").getBool().toString())
const map: Map<String, JsonValue> = value.asTable()
println(map.keys().len().toString())
println(Json::stringify(value))
return 0
}
}
fn jsonParse(text: String) → JsonValue
fn jsonStringify(value: JsonValue) → String
fn jsonGetString(value: JsonValue) → String
fn jsonGetInt(value: JsonValue) → Int64
fn jsonGetFloat(value: JsonValue) → Float64
fn jsonGetBool(value: JsonValue) → Bool
fn jsonIsNull(value: JsonValue) → Bool
fn jsonIsString(value: JsonValue) → Bool
fn jsonIsInt(value: JsonValue) → Bool
fn jsonIsFloat(value: JsonValue) → Bool
fn jsonIsBool(value: JsonValue) → Bool
fn jsonIsObject(value: JsonValue) → Bool
fn jsonIsArray(value: JsonValue) → Bool
fn jsonGetField(obj: JsonValue, key: String) → JsonValue
fn jsonGetObject(value: JsonValue) → Map<String, JsonValue>
fn jsonFromMap(map: Map<String, JsonValue>) → JsonValue
fn jsonIntArrayFromJson(arr: JsonValue) → List<Int64>
fn jsonIntArrayToString(arr: List<Int64>) → String
fn jsonIntArrayWrap(key: String, arr: List<Int64>) → String
fn jsonArrayLen(value: JsonValue) → Int64
fn jsonArrayGet(value: JsonValue, index: Int64) → JsonValue
class Json
Methods
fnc parse(text: String) → JsonValue
fnc stringify(value: JsonValue) → String
fnc getField(obj: JsonValue, key: String) → JsonValue
fnc fromMap(map: Map<String, JsonValue>) → JsonValue
fnc intArrayFromJson(arr: JsonValue) → List<Int64>
fnc intArrayToString(arr: List<Int64>) → String
fnc intArrayWrap(key: String, arr: List<Int64>) → String
fnc serialize(obj: T) → String
fnc deserialize(text: String) → T
@annotationclass JsonField
* Overrides the JSON field name for a class field. * Without this annotation, the field's Tinox name is used as-is. * * Usage: * @JsonField("first_name") * var firstName: String;
Fields
name | String |
Methods
fn new(name: String) → JsonField
@annotationclass JsonSerializable
* Marks a class for automatic JSON serialization and deserialization. * The compiler generates toJson() and fromJson(JsonValue) methods. * * Usage: * @JsonSerializable * class User * { * var id: Int64; * var name: String; * } * * const json: String = Json::serialize(user); * const user: User = Json::deserialize<User>(json);
class JsonValue
Methods
fn getString() → String
fn getInt() → Int64
fn asInt() → Int64
fn asTable() → Map<String, JsonValue>
fn getFloat() → Float64
fn getBool() → Bool
fn isNull() → Bool
fn isString() → Bool
fn isInt() → Bool
fn isFloat() → Bool
fn isBool() → Bool
fn isObject() → Bool
fn isArray() → Bool
fn getField(key: String) → JsonValue
fn len() → Int64
fn get(index: Int64) → JsonValue
fn asList() → List<JsonValue>