Wp.SpaJson

Fields

None

Methods

class

new_boolean (value)

class

new_float (value)

class

new_from_string (json_str)

class

new_from_stringn (json_str, len)

class

new_int (value)

class

new_null ()

class

new_string (value)

class

new_wrap (json)

class

new_wrap_string (json_str)

class

new_wrap_stringn (json_str, len)

copy ()

ensure_unique_owner ()

get_data ()

get_size ()

get_spa_json ()

is_array ()

is_boolean ()

is_container ()

is_float ()

is_int ()

is_null ()

is_object ()

is_string ()

is_unique_owner ()

new_iterator ()

parse_boolean ()

parse_float ()

parse_int ()

parse_string ()

ref ()

to_string ()

unref ()

Details

class Wp.SpaJson

New in version 0.4.8.

classmethod new_boolean(value)
Parameters:

value (bool) – the boolean value

Returns:

The new spa json

Return type:

Wp.SpaJson

Creates a spa json of type boolean.

classmethod new_float(value)
Parameters:

value (float) – the float value

Returns:

The new spa json

Return type:

Wp.SpaJson

Creates a spa json of type float.

classmethod new_from_string(json_str)
Parameters:

json_str (str) – a JSON string

Returns:

a new Wp.SpaJson; unlike the “wrap” variants, this function copies the data in json_str, so it does not need to stay alive.

Return type:

Wp.SpaJson

Constructs a new Wp.SpaJson from a JSON string.

New in version 0.5.0.

classmethod new_from_stringn(json_str, len)
Parameters:
  • json_str (str) – a JSON string

  • len (int) – the specific length of the string

Returns:

a new Wp.SpaJson; unlike the “wrap” variants, this function copies the data in json_str, so it does not need to stay alive.

Return type:

Wp.SpaJson

Constructs a new Wp.SpaJson from a JSON string with specific length.

New in version 0.5.0.

classmethod new_int(value)
Parameters:

value (int) – the int value

Returns:

The new spa json

Return type:

Wp.SpaJson

Creates a spa json of type int.

classmethod new_null()
Returns:

The new spa json

Return type:

Wp.SpaJson

Creates a spa json of type None.

classmethod new_string(value)
Parameters:

value (str) – the string value

Returns:

The new spa json

Return type:

Wp.SpaJson

Creates a spa json of type string.

classmethod new_wrap(json)
Parameters:

json (object or None) – a spa_json

Returns:

a new Wp.SpaJson that references the data in json. json is not copied, so it needs to stay alive.

Return type:

Wp.SpaJson

Constructs a new Wp.SpaJson that wraps the given spa_json.

classmethod new_wrap_string(json_str)
Parameters:

json_str (str) – a JSON string

Returns:

a new Wp.SpaJson that references the data in json_str. json_str is not copied, so it needs to stay alive.

Return type:

Wp.SpaJson

Constructs a new Wp.SpaJson that wraps a JSON string.

New in version 0.5.0.

classmethod new_wrap_stringn(json_str, len)
Parameters:
  • json_str (str) – a JSON string

  • len (int) – the specific length of the string

Returns:

a new Wp.SpaJson that references the data in json_str. json_str is not copied, so it needs to stay alive.

Return type:

Wp.SpaJson

Constructs a new Wp.SpaJson that wraps a JSON string with specific length.

New in version 0.5.0.

copy()
Returns:

The newly copied spa json

Return type:

Wp.SpaJson

Copies a spa json object.

ensure_unique_owner()
Returns:

the uniquely owned spa json object which may or may not be the same as self.

Return type:

Wp.SpaJson

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.

get_data()
Returns:

a const pointer to the json data

Return type:

str

Returns the json data.

get_size()
Returns:

the json data size

Return type:

int

Returns the json data size.

get_spa_json()
Returns:

a const pointer to the underlying spa_json structure

Return type:

object or None

Converts a Wp.SpaJson pointer to a struct spa_json one, for use with native pipewire & spa functions. The returned pointer is owned by Wp.SpaJson and may not be modified or freed.

is_array()
Returns:

True if it is of type array, False otherwise

Return type:

bool

Checks whether the spa json is of type array or not.

is_boolean()
Returns:

True if it is of type boolean, False otherwise

Return type:

bool

Checks wether the spa json is of type boolean or not.

is_container()
Returns:

True if it is of type container, False otherwise

Return type:

bool

Checks whether the spa json is of type container or not.

is_float()
Returns:

True if it is of type float, False otherwise

Return type:

bool

Checks wether the spa json is of type float or not.

is_int()
Returns:

True if it is of type int, False otherwise

Return type:

bool

Checks wether the spa json is of type int or not.

is_null()
Returns:

True if it is of type null, False otherwise

Return type:

bool

Checks wether the spa json is of type null or not.

is_object()
Returns:

True if it is of type object, False otherwise

Return type:

bool

Checks whether the spa json is of type object or not.

is_string()
Returns:

True if it is of type string, False otherwise

Return type:

bool

Checks wether the spa json is of type string or not.

is_unique_owner()
Returns:

True if the json owns the data, False otherwise.

Return type:

bool

Checks if the json is the unique owner of its data or not.

new_iterator()
Returns:

the new spa json iterator

Return type:

Wp.Iterator

Creates a new iterator for a spa json object.

parse_boolean()
Returns:

True if the value was obtained, False otherwise

value:

the boolean value

Return type:

(bool, value: bool)

Parses the boolean value of a spa json object.

parse_float()
Returns:

True if the value was obtained, False otherwise

value:

the float value

Return type:

(bool, value: float)

Parses the float value of a spa json object.

parse_int()
Returns:

True if the value was obtained, False otherwise

value:

the int value

Return type:

(bool, value: int)

Parses the int value of a spa json object.

parse_string()
Returns:

The newly allocated parsed string

Return type:

str

Parses the string value of a spa json object.

ref()
Returns:

self with an additional reference count on it

Return type:

Wp.SpaJson

Increases the reference count of a spa json object.

to_string()
Returns:

the json string with length matching the size

Return type:

str

Returns a newly allocated json string with length matching the size.

New in version 0.4.11.

unref()

Decreases the reference count on self and frees it when the ref count reaches zero.