pub struct Object { /* private fields */ }Expand description
JsonObject is the representation of the object type inside JSON.
A JsonObject contains Node “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 Json::Object::ref() and Json::Object::unref().
To add or overwrite a member with a given name, use set_member().
To extract a member with a given name, use member().
To retrieve the list of members, use members().
To retrieve the size of the object (that is, the number of members it has),
use size().
GLib type: Shared boxed type with reference counted clone semantics.
Implementations§
Source§impl Object
impl Object
Sourcepub fn as_ptr(&self) -> *mut JsonObject
pub fn as_ptr(&self) -> *mut JsonObject
Return the inner pointer to the underlying C value.
Sourcepub unsafe fn from_glib_ptr_borrow(ptr: &*mut JsonObject) -> &Self
pub unsafe fn from_glib_ptr_borrow(ptr: &*mut JsonObject) -> &Self
Borrows the underlying C value.
Source§impl Object
impl Object
Sourcepub fn dup_member(&self, member_name: &str) -> Option<Node>
pub fn dup_member(&self, member_name: &str) -> Option<Node>
Sourcepub fn foreach_member<P: FnMut(&Object, &str, &Node)>(&self, func: P)
pub fn foreach_member<P: FnMut(&Object, &str, &Node)>(&self, func: P)
Iterates over all members of @self and calls @func on each one of them.
It is safe to change the value of a member of the oobject from within the iterator function, but it is not safe to add or remove members from the object.
The order in which the object members are iterated is the insertion order.
§func
the function to be called on each member
Sourcepub fn array_member(&self, member_name: &str) -> Option<Array>
pub fn array_member(&self, member_name: &str) -> Option<Array>
Convenience function that retrieves the array
stored in @member_name of @self. It is an error to specify a
@member_name which does not exist or which holds a non-null, non-array
value.
If @member_name contains null, then this function will return NULL.
See also: member(), has_member()
§member_name
the name of the member
§Returns
the array inside the object’s member
Sourcepub fn is_boolean_member(&self, member_name: &str) -> bool
pub fn is_boolean_member(&self, member_name: &str) -> bool
Convenience function that retrieves the boolean value
stored in @member_name of @self. It is an error to specify a
@member_name which does not exist or which holds a non-scalar,
non-null value.
See also: [is_boolean_member_with_default()][Self::is_boolean_member_with_default()],
member(), has_member()
§member_name
the name of the member
§Returns
the boolean value of the object’s member
Sourcepub fn double_member(&self, member_name: &str) -> f64
pub fn double_member(&self, member_name: &str) -> f64
Convenience function that retrieves the floating point value
stored in @member_name of @self. It is an error to specify a
@member_name which does not exist or which holds a non-scalar,
non-null value.
See also: [double_member_with_default()][Self::double_member_with_default()],
member(), has_member()
§member_name
the name of the member
§Returns
the floating point value of the object’s member
Sourcepub fn int_member(&self, member_name: &str) -> i64
pub fn int_member(&self, member_name: &str) -> i64
Convenience function that retrieves the integer value
stored in @member_name of @self. It is an error to specify a
@member_name which does not exist or which holds a non-scalar,
non-null value.
See also: [int_member_with_default()][Self::int_member_with_default()],
member(), has_member()
§member_name
the name of the object member
§Returns
the integer value of the object’s member
Sourcepub fn is_null_member(&self, member_name: &str) -> bool
pub fn is_null_member(&self, member_name: &str) -> bool
Convenience function that checks whether the value stored in @member_name of @self is null. It is an error to specify a @member_name which does not exist.
See also: member(), has_member()
§member_name
the name of the member
§Returns
TRUE if the value is null
Sourcepub fn object_member(&self, member_name: &str) -> Option<Object>
pub fn object_member(&self, member_name: &str) -> Option<Object>
Convenience function that retrieves the object
stored in @member_name of @self. It is an error to specify a @member_name
which does not exist or which holds a non-null, non-object value.
If @member_name contains null, then this function will return NULL.
See also: member(), has_member()
§member_name
the name of the member
§Returns
the object inside the object’s member
Sourcepub fn string_member(&self, member_name: &str) -> GString
pub fn string_member(&self, member_name: &str) -> GString
Convenience function that retrieves the string value
stored in @member_name of @self. It is an error to specify a
@member_name that does not exist or which holds a non-scalar,
non-null value.
See also: [string_member_with_default()][Self::string_member_with_default()],
member(), has_member()
§member_name
the name of the member
§Returns
the string value of the object’s member
Sourcepub fn has_member(&self, member_name: &str) -> bool
pub fn has_member(&self, member_name: &str) -> bool
Sourcepub fn is_immutable(&self) -> bool
Available on crate feature v1_2 only.
pub fn is_immutable(&self) -> bool
v1_2 only.Sourcepub fn remove_member(&self, member_name: &str)
pub fn remove_member(&self, member_name: &str)
Removes @member_name from @self, freeing its allocated resources.
§member_name
the name of the member to remove
Sourcepub fn seal(&self)
Available on crate feature v1_2 only.
pub fn seal(&self)
v1_2 only.Seals the object, making it immutable to further changes.
This function will recursively seal all members of the object too.
If the object is already immutable, this is a no-op.
Sourcepub fn set_array_member(&self, member_name: &str, value: Array)
pub fn set_array_member(&self, member_name: &str, value: Array)
Convenience function for setting an object member with an array value.
See also: set_member(), Node::take_array()
§member_name
the name of the member
§value
the value of the member
Sourcepub fn set_boolean_member(&self, member_name: &str, value: bool)
pub fn set_boolean_member(&self, member_name: &str, value: bool)
Convenience function for setting an object member with a boolean value.
See also: set_member(), Node::init_boolean()
§member_name
the name of the member
§value
the value of the member
Sourcepub fn set_double_member(&self, member_name: &str, value: f64)
pub fn set_double_member(&self, member_name: &str, value: f64)
Convenience function for setting an object member with a floating point value.
See also: set_member(), Node::init_double()
§member_name
the name of the member
§value
the value of the member
Sourcepub fn set_int_member(&self, member_name: &str, value: i64)
pub fn set_int_member(&self, member_name: &str, value: i64)
Convenience function for setting an object member with an integer value.
See also: set_member(), Node::init_int()
§member_name
the name of the member
§value
the value of the member
Sourcepub fn set_member(&self, member_name: &str, node: Node)
pub fn set_member(&self, member_name: &str, node: Node)
Sourcepub fn set_null_member(&self, member_name: &str)
pub fn set_null_member(&self, member_name: &str)
Convenience function for setting an object member with a null value.
See also: set_member(), Node::init_null()
§member_name
the name of the member
Sourcepub fn set_object_member(&self, member_name: &str, value: Object)
pub fn set_object_member(&self, member_name: &str, value: Object)
Convenience function for setting an object member with an object value.
See also: set_member(), Node::take_object()
§member_name
the name of the member
§value
the value of the member
Sourcepub fn set_string_member(&self, member_name: &str, value: &str)
pub fn set_string_member(&self, member_name: &str, value: &str)
Convenience function for setting an object member with a string value.
See also: set_member(), Node::init_string()
§member_name
the name of the member
§value
the value of the member
Trait Implementations§
impl Eq for Object
v1_2 only.Source§impl HasParamSpec for Object
impl HasParamSpec for Object
Source§impl Ord for Object
impl Ord for Object
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Object
impl PartialOrd for Object
Source§impl StaticType for Object
impl StaticType for Object
Source§fn static_type() -> Type
fn static_type() -> Type
Self.