Object
Object Hierarchy:
Json.Object
Json.Object
Json.Object
Description:
[ CCode ( ref_function = "json_object_ref" , type_id = "json_object_get_type ()" , unref_function = "json_object_unref" ) ] [ Compact ]public class Object
`JsonObject` is the representation of the object type inside JSON.
A `JsonObject` contains [[email protected] ] "members", which may contain fundamental types, arrays or other objects; each member of an
object is accessed using a unique string, or "name".
Since objects can be arbitrarily big, copying them can be expensive; for this reason they are reference counted. You can control the
lifetime of a `JsonObject` using [[email protected] ] and [[email protected] ].
To add or overwrite a member with a given name, use [[email protected] _member].
To extract a member with a given name, use [[email protected] _member].
To retrieve the list of members, use [[email protected] _members].
To retrieve the size of the object (that is, the number of members it has), use [[email protected] _size].
Content:
Creation methods:
public Object ()
Creates a new object.
Methods:
public unowned Object @ref ()
Acquires a reference on the given object.
public void add_member (string member_name, owned Node node)
Adds a new member for the given name and value into an object.
public Node ? dup_member (string member_name)
Retrieves a copy of the value of the given member inside an object.
public bool equal (Object b)
Check whether this and b
are equal objects, meaning they have the same set of members, and the values of corresponding members are equal.
public void foreach_member (ObjectForeach func)
Iterates over all members of this
and calls func
on each one of them.
public unowned Array ? get_array_member (string member_name)
Convenience function that retrieves the array stored in
member_name
of this .
public bool get_boolean_member (string member_name)
Convenience function that retrieves the boolean value stored in
member_name
of this .
public bool get_boolean_member_with_default (string member_name, bool default_value)
Convenience function that retrieves the boolean value stored in
member_name
of this .
public double get_double_member (string member_name)
Convenience function that retrieves the floating point value stored in
member_name
of this .
public double get_double_member_with_default (string member_name, double default_value)
Convenience function that retrieves the floating point value stored in
member_name
of this .
public int64 get_int_member (string member_name)
Convenience function that retrieves the integer value stored in
member_name
of this .
public int64 get_int_member_with_default (string member_name, int64 default_value)
Convenience function that retrieves the integer value stored in
member_name
of this .
public unowned Node ? get_member (string member_name)
Retrieves the value of the given member inside an object.
public List <unowned string >? get_members ()
Retrieves all the names of the members of an object.
public bool get_null_member (string member_name)
Convenience function that checks whether the value stored in
member_name
of this is null.
public unowned Object ? get_object_member (string member_name)
Convenience function that retrieves the object stored in
member_name
of this .
public uint get_size ()
Retrieves the number of members of a JSON object.
public unowned string get_string_member (string member_name)
Convenience function that retrieves the string value stored in
member_name
of this .
public unowned string get_string_member_with_default (string member_name, string default_value)
Convenience function that retrieves the string value stored in
member_name
of this .
public List <unowned Node >? get_values ()
Retrieves all the values of the members of an object.
public bool has_member (string member_name)
Checks whether this has a member
named member_name
.
public uint hash ()
Calculate a hash value for the given this
(a JSON object).
public bool is_immutable ()
Checks whether the given object has been marked as immutable by
calling [method@Json.
public void remove_member (string member_name)
Removes member_name
from this
, freeing its allocated resources.
public void seal ()
Seals the object, making it immutable to further changes.
public void set_array_member (string member_name, owned Array value)
Convenience function for setting an object member with an array value.
public void set_boolean_member (string member_name, bool value)
Convenience function for setting an object member with a boolean
value.
public void set_double_member (string member_name, double value)
Convenience function for setting an object member with a floating
point value.
public void set_int_member (string member_name, int64 value)
Convenience function for setting an object member with an integer
value.
public void set_member (string member_name, owned Node node)
Sets the value of a member inside an object.
public void set_null_member (string member_name)
Convenience function for setting an object member with a `null` value.
public void set_object_member (string member_name, owned Object value)
Convenience function for setting an object member with an object
value.
public void set_string_member (string member_name, string value)
Convenience function for setting an object member with a string value.
public void unref ()
Releases a reference on the given object.