Spa Json¶
digraph inheritance { rankdir=LR; GBoxed -> WpSpaJson; GBoxed -> WpSpaJsonBuilder; GBoxed -> WpSpaJsonParser; }-
struct
WpSpaJson
¶ - Since
- 0.4.8
-
struct
WpSpaJsonBuilder
¶ - Since
- 0.4.8
-
struct
WpSpaJsonParser
¶ - Since
- 0.4.8
-
WpSpaJson*
wp_spa_json_ref
(WpSpaJson * self)¶ Increases the reference count of a spa json object.
- Return
- (transfer full): self with an additional reference count on it
- Parameters
self
: a spa json object
-
void
wp_spa_json_unref
(WpSpaJson * self)¶ Decreases the reference count on self and frees it when the ref count reaches zero.
- Parameters
self
: (transfer full): a spa json object
-
WpSpaJson*
wp_spa_json_new_from_string
(const gchar * json_str)¶ Constructs a new WpSpaJson from a JSON string.
- Return
- a new WpSpaJson that references the data in json_str. json_str is not copied, so it needs to stay alive.
- Parameters
json_str
: a JSON string
-
WpSpaJson*
wp_spa_json_new_from_stringn
(const gchar * json_str, size_t len)¶ Constructs a new WpSpaJson from a JSON string with specific length.
- Return
- a new WpSpaJson that references the data in json_str. json_str is not copied, so it needs to stay alive.
- Since
- 0.4.10
- Parameters
json_str
: a JSON stringlen
: the specific length of the string
-
WpSpaJson*
wp_spa_json_new_wrap
(struct spa_json * json)¶ Constructs a new WpSpaJson that wraps the given
spa_json
.- Return
- a new WpSpaJson that references the data in json. json is not copied, so it needs to stay alive.
- Parameters
json
: a spa_json
-
const struct spa_json*
wp_spa_json_get_spa_json
(const WpSpaJson * self)¶ Converts a WpSpaJson pointer to a
struct spa_json
one, for use with native pipewire & spa functions. The returned pointer is owned by WpSpaJson and may not be modified or freed.- Return
- a const pointer to the underlying spa_json structure
- Parameters
self
: a spa json object
-
const gchar*
wp_spa_json_get_data
(const WpSpaJson * self)¶ Returns the json data.
- Return
- a const pointer to the json data
- Parameters
self
: a spa json object
-
size_t
wp_spa_json_get_size
(const WpSpaJson * self)¶ Returns the json data size.
- Return
- the json data size
- Parameters
self
: a spa json object
-
gchar*
wp_spa_json_to_string
(const WpSpaJson * self)¶ Returns a newly allocated json string with length matching the size.
- Return
- (transfer full): the json string with length matching the size
- Since
- 0.4.11
- Parameters
self
: a spa json object
-
WpSpaJson*
wp_spa_json_copy
(WpSpaJson * other)¶ Copies a spa json object.
- Return
- (transfer full): The newly copied spa json
- Parameters
other
: a spa json object
-
gboolean
wp_spa_json_is_unique_owner
(WpSpaJson * self)¶ Checks if the json is the unique owner of its data or not.
- Return
- TRUE if the json owns the data, FALSE otherwise.
- Parameters
self
: a spa json object
-
WpSpaJson*
wp_spa_json_ensure_unique_owner
(WpSpaJson * self)¶ If self is not uniquely owned already, then it is unrefed and a copy of it is returned instead. You should always consider self as unsafe to use after this call and you should use the returned object instead.
- Return
- (transfer full): the uniquely owned spa json object which may or may not be the same as self.
- Parameters
self
: (transfer full): a spa json object
-
WpSpaJson*
wp_spa_json_new_null
(void)¶ Creates a spa json of type NULL.
- Return
- (transfer full): The new spa json
-
WpSpaJson*
wp_spa_json_new_boolean
(gboolean value)¶ Creates a spa json of type boolean.
- Return
- (transfer full): The new spa json
- Parameters
value
: the boolean value
-
WpSpaJson*
wp_spa_json_new_int
(gint value)¶ Creates a spa json of type int.
- Return
- (transfer full): The new spa json
- Parameters
value
: the int value
-
WpSpaJson*
wp_spa_json_new_float
(float value)¶ Creates a spa json of type float.
- Return
- (transfer full): The new spa json
- Parameters
value
: the float value
-
WpSpaJson*
wp_spa_json_new_string
(const gchar * value)¶ Creates a spa json of type string.
- Return
- (transfer full): The new spa json
- Parameters
value
: the string value
-
WpSpaJson*
wp_spa_json_new_array
(const gchar * format, ...)¶ Creates a spa json of type array.
- Return
- (transfer full): The new spa json
- Parameters
format
: (nullable): the first value format (“n”, “b”, “i”, “f”, “s” or “J”)...
: a list of array types and values, followed by NULL
-
WpSpaJson*
wp_spa_json_new_array_valist
(const gchar * format, va_list args)¶ This is the
va_list
version of wp_spa_json_new_array()- Return
- (transfer full): The new spa json
- Parameters
format
: (nullable): the first value format (“n”, “b”, “i”, “f”, “s” or “J”)args
: the variable arguments passed to wp_spa_json_new_array()
-
WpSpaJson*
wp_spa_json_new_object
(const gchar * key, const gchar * format, ...)¶ Creates a spa json of type object.
- Return
- (transfer full): The new spa json
- Parameters
key
: (nullable): the first object property keyformat
: (nullable): the first property format (“n”, “b”, “i”, “f”, “s” or “J”)...
: a list of object properties and values, followed by NULL
-
WpSpaJson*
wp_spa_json_new_object_valist
(const gchar * key, const gchar * format, va_list args)¶ This is the
va_list
version of wp_spa_json_new_object()- Return
- (transfer full): The new spa json
- Parameters
key
: (nullable): the first object property keyformat
: (nullable): the first property format (“n”, “b”, “i”, “f”, “s” or “J”)args
: the variable arguments passed to wp_spa_json_new_object()
-
gboolean
wp_spa_json_is_null
(WpSpaJson * self)¶ Checks wether the spa json is of type null or not.
- Return
- TRUE if it is of type null, FALSE otherwise
- Parameters
self
: the spa json object
-
gboolean
wp_spa_json_is_boolean
(WpSpaJson * self)¶ Checks wether the spa json is of type boolean or not.
- Return
- TRUE if it is of type boolean, FALSE otherwise
- Parameters
self
: the spa json object
-
gboolean
wp_spa_json_is_int
(WpSpaJson * self)¶ Checks wether the spa json is of type int or not.
- Return
- TRUE if it is of type int, FALSE otherwise
- Parameters
self
: the spa json object
-
gboolean
wp_spa_json_is_float
(WpSpaJson * self)¶ Checks wether the spa json is of type float or not.
- Return
- TRUE if it is of type float, FALSE otherwise
- Parameters
self
: the spa json object
-
gboolean
wp_spa_json_is_string
(WpSpaJson * self)¶ Checks wether the spa json is of type string or not.
- Return
- TRUE if it is of type string, FALSE otherwise
- Parameters
self
: the spa json object
-
gboolean
wp_spa_json_is_array
(WpSpaJson * self)¶ Checks wether the spa json is of type array or not.
- Return
- TRUE if it is of type array, FALSE otherwise
- Parameters
self
: the spa json object
-
gboolean
wp_spa_json_is_object
(WpSpaJson * self)¶ Checks wether the spa json is of type object or not.
- Return
- TRUE if it is of type object, FALSE otherwise
- Parameters
self
: the spa json object
-
gboolean
wp_spa_json_parse_boolean
(WpSpaJson * self, gboolean * value)¶ Parses the boolean value of a spa json object.
- Return
- TRUE if the value was obtained, FALSE otherwise
- Parameters
self
: the spa json objectvalue
: (out): the boolean value
-
gboolean
wp_spa_json_parse_int
(WpSpaJson * self, gint * value)¶ Parses the int value of a spa json object.
- Return
- TRUE if the value was obtained, FALSE otherwise
- Parameters
self
: the spa json objectvalue
: (out): the int value
-
gboolean
wp_spa_json_parse_float
(WpSpaJson * self, float * value)¶ Parses the float value of a spa json object.
- Return
- TRUE if the value was obtained, FALSE otherwise
- Parameters
self
: the spa json objectvalue
: (out): the float value
-
gchar*
wp_spa_json_parse_string
(WpSpaJson * self)¶ Parses the string value of a spa json object.
- Return
- (transfer full): The newly allocated parsed string
- Parameters
self
: the spa json object
-
gboolean
wp_spa_json_parse_array
(WpSpaJson * self, ...)¶ Parses the array types and values of a spa json object.
- Return
- TRUE if the types and values were obtained, FALSE otherwise
- Parameters
self
: the spa json object...
: (out): the list of array types and values, followed by NULL
-
gboolean
wp_spa_json_parse_array_valist
(WpSpaJson * self, va_list args)¶ This is the
va_list
version of wp_spa_json_parse_array()- Return
- TRUE if the types and values were obtained, FALSE otherwise
- Parameters
self
: the spa json objectargs
: (out): the variable arguments passed to wp_spa_json_parse_array()
-
gboolean
wp_spa_json_parse_object
(WpSpaJson * self, ...)¶ Parses the object properties and values of a spa json object.
- Return
- TRUE if the properties and values were obtained, FALSE otherwise
- Parameters
self
: the spa json object...
: (out): the list of object properties and values, followed by NULL
-
gboolean
wp_spa_json_parse_object_valist
(WpSpaJson * self, va_list args)¶ This is the
va_list
version of wp_spa_json_parse_object()- Return
- TRUE if the properties and values were obtained, FALSE otherwise
- Parameters
self
: the spa json objectargs
: (out): the variable arguments passed to wp_spa_json_parse_object()
-
gboolean
wp_spa_json_object_get
(WpSpaJson * self, ...)¶ Parses the object property values of a spa json object.
- Return
- TRUE if the properties and values were obtained, FALSE otherwise
- Parameters
self
: the spa json object...
: the list of property names, formats and values, followed by NULL
-
gboolean
wp_spa_json_object_get_valist
(WpSpaJson * self, va_list args)¶ This is the
va_list
version of wp_spa_json_object_get()- Return
- TRUE if the properties and values were obtained, FALSE otherwise
- Parameters
self
: the spa json objectargs
: the variable arguments passed to wp_spa_json_object_get()
-
WpSpaJsonBuilder*
wp_spa_json_builder_ref
(WpSpaJsonBuilder * self)¶ Increases the reference count of a spa json builder.
- Return
- (transfer full): self with an additional reference count on it
- Parameters
self
: a spa json builder object
-
void
wp_spa_json_builder_unref
(WpSpaJsonBuilder * self)¶ Decreases the reference count on self and frees it when the ref count reaches zero.
- Parameters
self
: (transfer full): a spa json builder object
-
WpSpaJsonBuilder*
wp_spa_json_builder_new_array
(void)¶ Creates a spa json builder of type array.
- Return
- (transfer full): the new spa json builder
-
WpSpaJsonBuilder*
wp_spa_json_builder_new_object
(void)¶ Creates a spa json builder of type object.
- Return
- (transfer full): the new spa json builder
-
void
wp_spa_json_builder_add_property
(WpSpaJsonBuilder * self, const gchar * key)¶ Adds a property into the builder.
- Parameters
self
: the spa json builder objectkey
: the name of the property
-
void
wp_spa_json_builder_add_null
(WpSpaJsonBuilder * self)¶ Adds a null value into the builder.
- Parameters
self
: the spa json builder object
-
void
wp_spa_json_builder_add_boolean
(WpSpaJsonBuilder * self, gboolean value)¶ Adds a boolean value into the builder.
- Parameters
self
: the spa json builder objectvalue
: the boolean value
-
void
wp_spa_json_builder_add_int
(WpSpaJsonBuilder * self, gint value)¶ Adds a int value into the builder.
- Parameters
self
: the spa json builder objectvalue
: the int value
-
void
wp_spa_json_builder_add_float
(WpSpaJsonBuilder * self, float value)¶ Adds a float value into the builder.
- Parameters
self
: the spa json builder objectvalue
: the float value
-
void
wp_spa_json_builder_add_string
(WpSpaJsonBuilder * self, const gchar * value)¶ Adds a string value into the builder.
- Parameters
self
: the spa json builder objectvalue
: the string value
-
void
wp_spa_json_builder_add_json
(WpSpaJsonBuilder * self, WpSpaJson * json)¶ Adds a json value into the builder.
- Parameters
self
: the spa json builder objectjson
: (transfer none): the json value
-
void
wp_spa_json_builder_add
(WpSpaJsonBuilder * self, ...)¶ Adds values into the builder.
- Parameters
self
: the spa json builder object...
: the json values
-
void
wp_spa_json_builder_add_valist
(WpSpaJsonBuilder * self, va_list args)¶ This is the
va_list
version of wp_spa_json_builder_add()- Parameters
self
: the spa json builder objectargs
: the variable arguments passed to wp_spa_json_builder_add()
-
WpSpaJson*
wp_spa_json_builder_end
(WpSpaJsonBuilder * self)¶ Ends the builder process and returns the constructed spa json object.
- Return
- (transfer full): the constructed spa json object
- Parameters
self
: the spa json builder object
-
WpSpaJsonParser*
wp_spa_json_parser_ref
(WpSpaJsonParser * self)¶ Increases the reference count of a spa json parser.
- Return
- (transfer full): self with an additional reference count on it
- Parameters
self
: a spa json parser object
-
void
wp_spa_json_parser_unref
(WpSpaJsonParser * self)¶ Decreases the reference count on self and frees it when the ref count reaches zero.
- Parameters
self
: (transfer full): a spa json parser object
-
WpSpaJsonParser*
wp_spa_json_parser_new_array
(WpSpaJson * json)¶ Creates a spa json array parser. The json object must be valid for the entire life-cycle of the returned parser.
- Return
- (transfer full): The new spa json parser
- Parameters
json
: the spa json array to parse
-
WpSpaJsonParser*
wp_spa_json_parser_new_object
(WpSpaJson * json)¶ Creates a spa json object parser. The json object must be valid for the entire life-cycle of the returned parser.
- Return
- (transfer full): The new spa json parser
- Parameters
json
: the spa json object to parse
-
gboolean
wp_spa_json_parser_get_null
(WpSpaJsonParser * self)¶ Gets the null value from a spa json parser.
- Return
- TRUE if the null value is present, FALSE otherwise
- Parameters
self
: the spa json parser object
-
gboolean
wp_spa_json_parser_get_boolean
(WpSpaJsonParser * self, gboolean * value)¶ Gets the boolean value from a spa json parser.
- Return
- TRUE if the value was obtained, FALSE otherwise
- Parameters
self
: the spa json parser objectvalue
: (out): the boolean value
-
gboolean
wp_spa_json_parser_get_int
(WpSpaJsonParser * self, gint * value)¶ Gets the int value from a spa json parser object.
- Return
- TRUE if the value was obtained, FALSE otherwise
- Parameters
self
: the spa json parser objectvalue
: (out): the int value
-
gboolean
wp_spa_json_parser_get_float
(WpSpaJsonParser * self, float * value)¶ Gets the float value from a spa json parser object.
- Return
- TRUE if the value was obtained, FALSE otherwise
- Parameters
self
: the spa json parser objectvalue
: (out): the float value
-
gchar*
wp_spa_json_parser_get_string
(WpSpaJsonParser * self)¶ Gets the string value from a spa json parser object.
- Return
- (transfer full): The newly allocated parsed string
- Parameters
self
: the spa json parser object
-
WpSpaJson*
wp_spa_json_parser_get_json
(WpSpaJsonParser * self)¶ Gets the spa json value from a spa json parser object.
- Return
- (transfer full): The spa json value or NULL if it could not be obtained
- Parameters
self
: the spa json parser object
-
gboolean
wp_spa_json_parser_get
(WpSpaJsonParser * self, ...)¶ Gets the values from a spa json parser object.
- Return
- TRUE if the value was obtained, FALSE otherwise
- Parameters
self
: the spa json parser object...
: (out): a list of values to get, followed by NULL
-
gboolean
wp_spa_json_parser_get_valist
(WpSpaJsonParser * self, va_list args)¶ This is the
va_list
version of wp_spa_json_parser_get()- Return
- TRUE if the value was obtained, FALSE otherwise
- Parameters
self
: the spa json parser objectargs
: the variable arguments passed to wp_spa_json_parser_get()
-
WpIterator*
wp_spa_json_new_iterator
(WpSpaJson * self)¶ Creates a new iterator for a spa json object.
- Return
- (transfer full): the new spa json iterator
- Parameters
self
: the spa json object
-
WP_TYPE_SPA_JSON
(wp_spa_json_get_type ())¶ The WpSpaJson GType.
-
WP_TYPE_SPA_JSON_BUILDER
(wp_spa_json_builder_get_type ())¶ The WpSpaJsonBuilder GType.
-
WP_TYPE_SPA_JSON_PARSER
(wp_spa_json_parser_get_type ())¶ The WpSpaJsonParser GType.