json
Generated by tinox doc
JSON parsing and generation. Json::serialize/deserialize<T> work directly with @JsonSerializable-annotated classes; Json::parse/stringify and the JsonValue wrapper (getString/getInt/asTable/asList/isObject/...) give untyped access for dynamic/unknown-shape JSON.
Parse and read
import tinox.core.json;
class Main
{
fnc main() -> Int32
{
let value: JsonValue = Json::parse("{\"name\": \"tinox\", \"stable\": true}");
println(value.getField("name").getString());
println(value.getField("stable").getBool().toString());
let 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
@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
@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; * } * * let json: String = Json::serialize(user); * let user: User = Json::deserialize<User>(json);