Functions¶
| boxed_can_deserialize(gboxed_type, node_type) | |
| boxed_can_serialize(gboxed_type) | |
| boxed_deserialize(gboxed_type, node) | |
| boxed_serialize(gboxed_type, boxed) | |
| construct_gobject(gtype, data, length) | |
| from_string(str) | |
| gobject_deserialize(gtype, node) | |
| gobject_from_data(gtype, data, length) | |
| gobject_serialize(gobject) | |
| gobject_to_data(gobject) | |
| gvariant_deserialize(json_node, signature) | |
| gvariant_deserialize_data(json, length, signature) | |
| gvariant_serialize(variant) | |
| gvariant_serialize_data(variant) | |
| parser_error_quark() | |
| path_error_quark() | |
| reader_error_quark() | |
| serialize_gobject(gobject) | |
| string_compare(a, b) | |
| string_equal(a, b) | |
| string_hash(key) | |
| to_string(node, pretty) | 
Details¶
- 
Json.boxed_can_deserialize(gboxed_type, node_type)¶
- Parameters: - gboxed_type (GObject.GType) – a boxed type
- node_type (Json.NodeType) – aJson.Nodetype
 - Returns: - Return type: - Checks whether it is possible to deserialize a - GObject.GBoxedof type gboxed_type from a- Json.Nodeof type node_type- New in version 0.10. 
- gboxed_type (
- 
Json.boxed_can_serialize(gboxed_type)¶
- Parameters: - gboxed_type ( - GObject.GType) – a boxed type- Returns: - Trueif the type can be serialized, and- Falseotherwise.- node_type: - the - Json.Nodetype to which the boxed type can be serialized into- Return type: - ( - bool, node_type:- Json.NodeType)- Checks whether it is possible to serialize a - GObject.GBoxedof type gboxed_type into a- Json.Node. The type of the- Json.Nodeis placed inside node_type if the function returns- Trueand it’s undefined otherwise.- New in version 0.10. 
- 
Json.boxed_deserialize(gboxed_type, node)¶
- Parameters: - gboxed_type (GObject.GType) – a boxed type
- node (Json.Node) – aJson.Node
 - Returns: - the newly allocated - GObject.GBoxed. Use- GObject.boxed_free() to release the resources allocated by this function- Return type: - Deserializes node into a - GObject.GBoxedof gboxed_type- New in version 0.10. 
- gboxed_type (
- 
Json.boxed_serialize(gboxed_type, boxed)¶
- Parameters: - gboxed_type (GObject.GType) – a boxed type
- boxed (objectorNone) – a pointer to aGObject.GBoxedof type gboxed_type
 - Returns: - a - Json.Nodewith the serialization of the boxed type, or- Noneif serialization either failed or was not possible- Return type: - Serializes boxed, a pointer to a - GObject.GBoxedof type gboxed_type, into a- Json.Node- New in version 0.10. 
- gboxed_type (
- 
Json.construct_gobject(gtype, data, length)¶
- Parameters: - gtype (GObject.GType) – theGObject.GTypeof object to construct
- data (str) – a JSON data stream
- length (int) – length of the data stream
 - Raises: - Returns: - a - GObject.Objector- None- Return type: - Deserializes a JSON data stream and creates the corresponding - GObject.Objectclass. If gtype implements the- Json.SerializableIfaceinterface, it will be asked to deserialize all the JSON members into the respective properties; otherwise, the default implementation will be used to translate the compatible JSON native types.- Note: the JSON data stream must be an object declaration. - New in version 0.4. - Deprecated since version 0.10: Use - Json.gobject_from_data() instead
- gtype (
- 
Json.from_string(str)¶
- Parameters: - str ( - str) – a valid UTF-8 string containing JSON data- Raises: - GLib.Error- Returns: - a - Json.Node, or- None- Return type: - Json.Nodeor- None- Parses the string in str and returns a - Json.Noderepresenting the JSON tree. If str is empty, this function will return- None.- In case of parsing error, this function returns - Noneand sets error appropriately.- New in version 1.2. 
- 
Json.gobject_deserialize(gtype, node)¶
- Parameters: - gtype (GObject.GType) – the type of theGObject.Objectto create
- node (Json.Node) – aJson.Nodeof typeJson.NodeType.OBJECTdescribing the instance of type gtype
 - Returns: - The newly created - GObject.Objectinstance. Use- GObject.Object.unref() to free the resources allocated by this function- Return type: - Creates a new - GObject.Objectof type gtype, and constructs it using the members of the passed- Json.Object- New in version 0.10. 
- gtype (
- 
Json.gobject_from_data(gtype, data, length)¶
- Parameters: - gtype (GObject.GType) – theGObject.GTypeof object to construct
- data (str) – a JSON data stream
- length (int) – length of the data stream, or -1 if it is NUL-terminated
 - Raises: - Returns: - a - GObject.Objector- None- Return type: - Deserializes a JSON data stream and creates the corresponding - GObject.Objectclass. If gtype implements the- Json.SerializableIfaceinterface, it will be asked to deserialize all the JSON members into the respective properties; otherwise, the default implementation will be used to translate the compatible JSON native types.- Note: the JSON data stream must be an object declaration. - New in version 0.10. 
- gtype (
- 
Json.gobject_serialize(gobject)¶
- Parameters: - gobject ( - GObject.Object) – a- GObject.Object- Returns: - the newly created - Json.Nodeof type- Json.NodeType.OBJECT. Use- Json.Node.unref() to free the resources allocated by this function- Return type: - Json.Node- Creates a - Json.Noderepresenting the passed- GObject.Objectinstance. Each member of the returned JSON object will map to a property of the- GObject.Object- New in version 0.10. 
- 
Json.gobject_to_data(gobject)¶
- Parameters: - gobject ( - GObject.Object) – a- GObject.Object- Returns: - a JSON data stream representing the passed - GObject.Object- length: - return value for the length of the buffer, or - None- Return type: - ( - str, length:- int)- Serializes a - GObject.Objectinto a JSON data stream, iterating recursively over each property.- If gobject implements the - Json.SerializableIfaceinterface, it will be asked to serialize all its properties; otherwise, the default implementation will be use to translate the compatible types into JSON native types.- New in version 0.10. 
- 
Json.gvariant_deserialize(json_node, signature)¶
- Parameters: - Raises: - Returns: - A newly created, floating - GLib.Variantcompliant with signature, or- Noneon error- Return type: - Converts a JSON data structure to a - GLib.Variantvalue using signature to resolve ambiguous data types. If no error occurs, the resulting- GLib.Variantis guaranteed to conform to signature.- If signature is not - Nonebut does not represent a valid- GLib.Varianttype string,- Noneis returned and error is set to- Gio.IOErrorEnum.INVALID_ARGUMENT. If a signature is provided but the JSON structure cannot be mapped to it,- Noneis returned and error is set to- Gio.IOErrorEnum.INVALID_DATA. If signature is- None, the conversion is done based strictly on the types in the JSON nodes.- The returned variant has a floating reference that will need to be sunk by the caller code. - New in version 0.14. 
- 
Json.gvariant_deserialize_data(json, length, signature)¶
- Parameters: - Raises: - Returns: - A newly created, floating - GLib.Variantcompliant with signature, or- Noneon error- Return type: - Converts a JSON string to a - GLib.Variantvalue. This method works exactly like- Json.gvariant_deserialize(), but takes a JSON encoded string instead. The string is first converted to a- Json.Nodeusing- Json.Parser, and then- Json.gvariant_deserialize() is called.- The returned variant has a floating reference that will need to be sunk by the caller code. - New in version 0.14. 
- 
Json.gvariant_serialize(variant)¶
- Parameters: - variant ( - GLib.Variant) – A- GLib.Variantto convert- Returns: - A - Json.Noderepresenting the root of the JSON data structure obtained from variant- Return type: - Json.Node- Converts variant to a JSON tree. - New in version 0.14. 
- 
Json.gvariant_serialize_data(variant)¶
- Parameters: - variant ( - GLib.Variant) – A- GLib.Variantto convert- Returns: - The JSON encoded string corresponding to variant - length: - Return location for the length of the returned string, or - None- Return type: - ( - str, length:- int)- Converts variant to its JSON encoded string representation. This method is actually a helper function. It uses - Json.gvariant_serialize() to obtain the JSON tree, and then- Json.Generatorto stringify it.- New in version 0.14. 
- 
Json.serialize_gobject(gobject)¶
- Parameters: - gobject ( - GObject.Object) – a- GObject.Object- Returns: - a JSON data stream representing the passed - GObject.Object- length: - return value for the length of the buffer, or - None- Return type: - ( - str, length:- int)- Serializes a - GObject.Objectinto a JSON data stream. If gobject implements the- Json.SerializableIfaceinterface, it will be asked to serizalize all its properties; otherwise, the default implementation will be use to translate the compatible types into JSON native types.- Deprecated since version 0.10: Use - Json.gobject_to_data() instead
- 
Json.string_compare(a, b)¶
- Parameters: - Returns: - an integer less than zero if a < b, equal to zero if a == b, and greater than zero if a > b - Return type: - Check whether a and b are equal UTF-8 JSON strings and return an ordering over them in strcmp() style. - New in version 1.2. 
- 
Json.string_equal(a, b)¶
- Parameters: - Returns: - Return type: - Check whether a and b are equal UTF-8 JSON strings. - New in version 1.2. 
- 
Json.string_hash(key)¶
- Parameters: - key ( - str) – a JSON string to hash- Returns: - hash value for key - Return type: - int- Calculate a hash value for the given key (a UTF-8 JSON string). - Note: Member names are compared byte-wise, without applying any Unicode decomposition or normalisation. This is not explicitly mentioned in the JSON standard (ECMA-404), but is assumed. - New in version 1.2.