JsonValue
Object Hierarchy:
Description:
public class JsonValue : Object
Represents one JSON value.
JsonValue is the core type for all JSON data. It can represent objects, arrays, strings, numbers, booleans, and null.
Use factory methods to create values:
var s = JsonValue.ofString ("hello");
var n = JsonValue.ofInt (42);
var obj = JsonValue.object ()
.put ("name", JsonValue.ofString ("Alice"))
.build ();
Content:
Static methods:
- public static JsonArrayBuilder array ()
Creates a new JsonArrayBuilder for building JSON arrays.
- public static JsonObjectBuilder object ()
Creates a new JsonObjectBuilder for building JSON objects.
- public static JsonValue ofBool (bool value)
Creates a boolean JSON value.
- public static JsonValue ofDouble (double value)
Creates a floating-point JSON value.
- public static JsonValue ofInt (int value)
Creates an integer JSON value.
- public static JsonValue ofNull ()
Creates a null JSON value.
- public static JsonValue ofString (string value)
Creates a string JSON value.
Methods:
- public JsonValue? @get (string key)
Returns the value for a key in a JSON object.
- public bool? asBool ()
Returns the boolean content if this is a boolean value.
- public double? asDouble ()
Returns the double content if this is a number value.
- public int? asInt ()
Returns the integer content if this is a number value.
- public int asIntOr (int fallback)
Returns the integer content or a fallback if not a number.
- public string? asString ()
Returns the string content if this is a string value.
- public string asStringOr (string fallback)
Returns the string content or a fallback if not a string.
- public JsonValue? at (int index)
Returns the value at an index in a JSON array.
- public bool equals (JsonValue other)
Structural equality comparison.
- public bool isArray ()
Returns true if this value is a JSON array.
- public bool isBool ()
Returns true if this value is a JSON boolean.
- public bool isNull ()
Returns true if this value is JSON null.
- public bool isNumber ()
Returns true if this value is a JSON number (int or double).
- public bool isObject ()
Returns true if this value is a JSON object.
- public bool isString ()
Returns true if this value is a JSON string.
- public ArrayList<string>? keys ()
Returns the keys of a JSON object.
- public int size ()
Returns the number of entries (object keys or array elements).
- public ArrayList<JsonValue>? toList ()
Converts a JSON array to an ArrayList.
- public JsonValueType valueType ()
Returns the value type.
Inherited Members:
All known members inherited from class GLib.Object
- @get
- @new
- @ref
- @set
- add_toggle_ref
- add_weak_pointer
- bind_property
- connect
- constructed
- disconnect
- dispose
- dup_data
- dup_qdata
- force_floating
- freeze_notify
- get_class
- get_data
- get_property
- get_qdata
- get_type
- getv
- interface_find_property
- interface_install_property
- interface_list_properties
- is_floating
- new_valist
- new_with_properties
- newv
- notify
- notify_property
- ref_count
- ref_sink
- remove_toggle_ref
- remove_weak_pointer
- replace_data
- replace_qdata
- set_data
- set_data_full
- set_property
- set_qdata
- set_qdata_full
- set_valist
- setv
- steal_data
- steal_qdata
- thaw_notify
- unref
- watch_closure
- weak_ref
- weak_unref