A JSON array type. The contents of the #JsonArray structure are private and should only be accessed by the provided API Creates a new #JsonArray. the newly created #JsonArray Creates a new #JsonArray with @n_elements slots already allocated. the newly created #JsonArray number of slots to pre-allocate Conveniently adds an array into @array. The @array takes ownership of the newly added #JsonArray a #JsonArray Conveniently adds a boolean @value into @array a boolean value Conveniently adds a floating point @value into @array a floating point value Appends @node inside @array. The array will take ownership of the #JsonNode. a #JsonNode Conveniently adds an integer @value into @array an integer value Conveniently adds a null element into @array Conveniently adds an object into @array. The @array takes ownership of the newly added #JsonObject a #JsonObject Conveniently adds a string @value into @array a string value Retrieves a copy of the #JsonNode containing the value of the element at @index_ inside a #JsonArray index. Use json_node_free() when done. a copy of the #JsonNode at the requested the index of the element to retrieve Iterates over all elements of @array and calls @func on each one of them. It is safe to change the value of a #JsonNode of the @array from within the iterator @func, but it is not safe to add or remove elements from the @array. the function to be called on each element data to be passed to the function Conveniently retrieves the array from the element at @index_ inside @array the array the index of the element to retrieve Conveniently retrieves the boolean value of the element at @index_ inside @array the integer value the index of the element to retrieve Conveniently retrieves the floating point value of the element at the floating point value the index of the element to retrieve Retrieves the #JsonNode containing the value of the element at @index_ inside a #JsonArray. a pointer to the #JsonNode at the requested index the index of the element to retrieve Gets the elements of a #JsonArray as a list of #JsonNode<!-- -->s. containing the elements of the array. The contents of the list are owned by the array and should never be modified or freed. Use g_list_free() on the returned list when done using it a #GList Conveniently retrieves the integer value of the element at @index_ inside @array the integer value the index of the element to retrieve Retrieves the length of a #JsonArray the length of the array Conveniently retrieves whether the element at @index_ is set to null %TRUE if the element is null the index of the element to retrieve Conveniently retrieves the object from the element at @index_ inside @array the object the index of the element to retrieve Conveniently retrieves the string value of the element at @index_ inside @array the #JsonArray and should not be modified or freed the string value; the returned string is owned by the index of the element to retrieve Increase by one the reference count of a #JsonArray. increased by one. the passed #JsonArray, with the reference count Removes the #JsonNode inside @array at @index_ freeing its allocated resources. the position of the element to be removed Decreases by one the reference count of a #JsonArray. If the reference count reaches zero, the array is destroyed and all its allocated resources are freed. The function to be passed to json_array_foreach_element(). You should not add or remove elements to and from @array within this function. It is safe to change the value of @element_node. the iterated #JsonArray the index of the element a #JsonNode containing the value at @index_ data passed to the function Deserializes the contents of the passed #JsonNode into a #GBoxed the newly created boxed type a #JsonNode Serializes the passed #GBoxed and stores it inside a #JsonNode the newly created #JsonNode a #GBoxed The <structname>JsonBuilder</structname> structure contains only private data and shouls be accessed using the provided API Creates a new #JsonBuilder. You can use this object to generate a JSON tree and obtain the root #JsonNode<!-- -->s. the newly created #JsonBuilder instance If called after json_builder_set_member_name(), sets @value as member of the most recent opened object, otherwise @value is added as element of the most recent opened array. the #JsonBuilder, or %NULL if the call was inconsistent the value of the member or element If called after json_builder_set_member_name(), sets @value as member of the most recent opened object, otherwise @value is added as element of the most recent opened array. the #JsonBuilder, or %NULL if the call was inconsistent the value of the member or element If called after json_builder_set_member_name(), sets @value as member of the most recent opened object, otherwise @value is added as element of the most recent opened array. the #JsonBuilder, or %NULL if the call was inconsistent the value of the member or element If called after json_builder_set_member_name(), sets null as member of the most recent opened object, otherwise null is added as element of the most recent opened array. the #JsonBuilder, or %NULL if the call was inconsistent If called after json_builder_set_member_name(), sets @value as member of the most recent opened object, otherwise @value is added as element of the most recent opened array. the #JsonBuilder, or %NULL if the call was inconsistent the value of the member or element If called after json_builder_set_member_name(), sets @node as member of the most recent opened object, otherwise @node is added as element of the most recent opened array. the #JsonBuilder, or %NULL if the call was inconsistent the value of the member or element Opens a subarray inside the given @builder. When done adding members to the subarray, json_builder_end_array() must be called. Can be called for first or only if the call is associated to an object member or an array element. the #JsonBuilder, or %NULL if the call was inconsistent Opens a subobject inside the given @builder. When done adding members to the subobject, json_builder_end_object() must be called. Can be called for first or only if the call is associated to an object member or an array element. the #JsonBuilder, or %NULL if the call was inconsistent Closes the subarray inside the given @builder that was opened by the most recent call to json_builder_begin_array(). Cannot be called after json_builder_set_member_name(). the #JsonBuilder, or %NULL if the call was inconsistent Closes the subobject inside the given @builder that was opened by the most recent call to json_builder_begin_object(). Cannot be called after json_builder_set_member_name(). the #JsonBuilder, or %NULL if the call was inconsistent Returns the root of the current constructed tree, if the build is complete (ie: all opened objects, object members and arrays are being closed). Free the returned value with json_node_free(). the #JsonNode, or %NULL if the build is not complete. Resets the state of the @builder back to its initial state. Set the name of the next member in an object. The next call must add a value, open an object or an array. Can be called only if the call is associated to an object. the #JsonBuilder, or %NULL if the call was inconsistent the name of the member The <structname>JsonBuilder</structname> structure contains only private data JSON data streams generator. The contents of the #JsonGenerator structure are private and should only be accessed via the provided API. Creates a new #JsonGenerator. You can use this object to generate a JSON data stream starting from a data object model composed by #JsonNode<!-- -->s. the newly created #JsonGenerator instance Sets @node as the root of the JSON data stream to be serialized by the #JsonGenerator. <note>The node is copied by the generator object, so it can be safely freed after calling this function.</note> a #JsonNode Generates a JSON data stream from @generator and returns it as a buffer. Use g_free() to free the allocated resources. a newly allocated buffer holding a JSON data stream. return location for the length of the returned buffer, or %NULL Creates a JSON data stream and puts it inside @filename, overwriting the current file contents. This operation is atomic. %TRUE if saving was successful. path to the target file Outputs JSON data and streams it (synchronously) to @stream. on failure. In case of error, the #GError will be filled accordingly %TRUE if the write operation was successful, and %FALSE a #GOutputStream a #GCancellable, or %NULL Number of spaces to be used to indent when pretty printing. The character that should be used when indenting in pretty print. Whether the output should be "pretty-printed", with indentation and newlines. The indentation level can be controlled by using the JsonGenerator:indent property The root #JsonNode to be used when constructing a JSON data stream. #JsonGenerator class A generic container of JSON data types. The contents of the #JsonNode structure are private and should only be accessed via the provided functions and never directly. Creates a new #JsonNode of @type. the newly created #JsonNode a #JsonNodeType Copies @node. If the node contains complex data types then the reference count of the objects is increased. the copied #JsonNode Retrieves the #JsonObject inside @node. The reference count of the returned object is increased. the #JsonObject Gets a copy of the string value stored inside a #JsonNode of the #JsonNode contents. Use g_free() to free the allocated resources a newly allocated string containing a copy Frees the resources allocated by @node. Retrieves the #JsonArray stored inside a #JsonNode the #JsonArray Gets the boolean value stored inside a #JsonNode a boolean value. Gets the double value stored inside a #JsonNode a double value. Gets the integer value stored inside a #JsonNode an integer value. Retrieves the #JsonNodeType of @node the type of the node Retrieves the #JsonObject stored inside a #JsonNode the #JsonObject Retrieves the parent #JsonNode of @node. the root node the parent node, or %NULL if @node is Gets the string value stored inside a #JsonNode a string value. Retrieves a value from a #JsonNode and copies into @value. When done using it, call g_value_unset() on the #GValue. return location for an uninitialized value Returns the #GType of the payload of the node. a #GType for the payload. Checks whether @node is a %JSON_NODE_NULL <note>A null node is not the same as a %NULL #JsonNode</note> %TRUE if the node is null Sets @array inside @node and increases the #JsonArray reference count a #JsonArray Sets @value as the boolean content of the @node, replacing any existing content. a boolean value Sets @value as the double content of the @node, replacing any existing content. a double value Sets @value as the integer content of the @node, replacing any existing content. an integer value Sets @objects inside @node. The reference count of @object is increased. a #JsonObject Sets the parent #JsonNode of @node the parent #JsonNode of @node Sets @value as the string content of the @node, replacing any existing content. a string value Sets @value inside @node. The passed #GValue is copied into the #JsonNode the #GValue to set Sets @array into @node without increasing the #JsonArray reference count. a #JsonArray Sets @object inside @node. The reference count of @object is not increased. a #JsonObject Retrieves the user readable name of the data type contained by @node. is owned by the node and should never be modified or freed a string containing the name of the type. The returned string Indicates the content of a #JsonNode. A JSON object type. The contents of the #JsonObject structure are private and should only be accessed by the provided API Creates a new #JsonObject, an JSON object type representation. the newly created #JsonObject Adds a member named @member_name and containing @node into a #JsonObject. The object will take ownership of the #JsonNode. This function will return if the @object already contains a member the name of the member the value of the member Retrieves a copy of the #JsonNode containing the value of @member_name inside a #JsonObject object member or %NULL. Use json_node_free() when done. a copy of the node for the requested the name of the JSON object member to access Iterates over all members of @object and calls @func on each one of them. It is safe to change the value of a #JsonNode of the @object from within the iterator @func, but it is not safe to add or remove members from the @object. the function to be called on each member data to be passed to the function Convenience function that retrieves the array stored in @member_name of @object the array inside the object's member the name of the member Convenience function that retrieves the boolean value stored in @member_name of @object the boolean value of the object's member the name of the member Convenience function that retrieves the floating point value stored in @member_name of @object the floating point value of the object's member the name of the member Convenience function that retrieves the integer value stored in @member_name of @object the integer value of the object's member the name of the member Retrieves the #JsonNode containing the value of @member_name inside a #JsonObject. member, or %NULL a pointer to the node for the requested object the name of the JSON object member to access Retrieves all the names of the members of a #JsonObject. You can obtain the value for each member using json_object_get_member(). of member names. The content of the list is owned by the #JsonObject and should never be modified or freed. When you have finished using the returned list, use g_list_free() to free the resources it has allocated. a #GList Convenience function that checks whether the value stored in @member_name of @object is null %TRUE if the value is null the name of the member Convenience function that retrieves the object stored in @member_name of @object the object inside the object's member the name of the member Retrieves the number of members of a #JsonObject. the number of members Convenience function that retrieves the string value stored in @member_name of @object the string value of the object's member the name of the member Retrieves all the values of the members of a #JsonObject. #JsonNode<!-- -->s. The content of the list is owned by the #JsonObject and should never be modified or freed. When you have finished using the returned list, use g_list_free() to free the resources it has allocated. a #GList of Checks whether @object has a member named @member_name. %TRUE if the JSON object has the requested member the name of a JSON object member Increase by one the reference count of a #JsonObject. increased by one. the passed #JsonObject, with the reference count Removes @member_name from @object, freeing its allocated resources. the name of the member to remove Convenience function for setting an array @value of The @object will take ownership of the passed #JsonArray the name of the member the value of the member Convenience function for setting a boolean @value of the name of the member the value of the member Convenience function for setting a floating point @value of @member_name inside @object. the name of the member the value of the member Convenience function for setting an integer @value of the name of the member the value of the member Sets @node as the value of @member_name inside @object. If @object already contains a member called @member_name then the member's current value is overwritten. Otherwise, a new member is added to @object. the name of the member the value of the member Convenience function for setting a null @value of the name of the member Convenience function for setting an object @value of The @object will take ownership of the passed #JsonObject the name of the member the value of the member Convenience function for setting a string @value of the name of the member the value of the member Decreases by one the reference count of a #JsonObject. If the reference count reaches zero, the object is destroyed and all its allocated resources are freed. The function to be passed to json_object_foreach_member(). You should not add or remove members to and from @object within this function. It is safe to change the value of @member_node. the iterated #JsonObject the name of the member a #JsonNode containing the @member_name value data passed to the function JSON data streams parser. The contents of the #JsonParser structure are private and should only be accessed via the provided API. Creates a new #JsonParser instance. You can use the #JsonParser to load a JSON stream from either a file or a buffer and then walk the hierarchy using the data types API. to release all the memory it allocates. the newly created #JsonParser. Use g_object_unref() Retrieves the line currently parsed, starting from 1. This function has defined behaviour only while parsing; calling this function from outside the signal handlers emitted by #JsonParser will yield 0. the currently parsed line, or 0. Retrieves the current position inside the current line, starting from 0. This function has defined behaviour only while parsing; calling this function from outside the signal handlers emitted by #JsonParser will yield 0. the position in the current line, or 0. Retrieves the top level node from the parsed JSON stream. node is owned by the #JsonParser and should never be modified or freed. the root #JsonNode . The returned A JSON data stream might sometimes contain an assignment, like: |[ ]| even though it would technically constitute a violation of the RFC. #JsonParser will ignore the left hand identifier and parse the right hand value of the assignment. #JsonParser will record, though, the existence of the assignment in the data stream and the variable name used. used in the assignment. The string is owned by #JsonParser and should never be modified or freed. %TRUE if there was an assignment, %FALSE otherwise. If Return location for the variable name, or %NULL Loads a JSON stream from a buffer and parses it. You can call this function multiple times with the same #JsonParser object, but the contents of the parser will be destroyed each time. of error, @error is set accordingly and %FALSE is returned %TRUE if the buffer was succesfully parser. In case the buffer to parse the length of the buffer, or -1 Loads a JSON stream from the content of @filename and parses it. See json_parser_load_from_data(). In case of error, @error is set accordingly and %FALSE is returned %TRUE if the file was successfully loaded and parsed. the path for the file to parse Loads the contents of an input stream and parses them. If @cancellable is not %NULL, then the operation can be cancelled by triggering the @cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be set on the passed @error. parsed, and %FALSE otherwise %TRUE if the data stream was successfully read and an open #GInputStream a #GCancellable, or %NULL Asynchronously reads the contents of @stream. For more details, see json_parser_load_from_stream() which is the synchronous version of this call. When the operation is finished, @callback will be called. You should then call json_parser_load_from_stream_finish() to get the result of the operation. a #GInputStream a #GCancellable, or %NULL a #GAsyncReadyCallback to call when the request is satisfied the data to pass to @callback Finishes an asynchronous stream loading started with json_parser_load_from_stream_async(). and parsed, and %FALSE otherwise. In case of error, the #GError will be filled accordingly. %TRUE if the content of the stream was successfully retrieves a #GAsyncResult The ::array-element signal is emitted each time the #JsonParser has successfully parsed a single element of a #JsonArray. The array and element index are passed to the signal handlers. a #JsonArray the index of the newly parsed element The ::array-end signal is emitted each time the #JsonParser has successfully parsed an entire #JsonArray the parsed #JsonArray The ::array-start signal is emitted each time the #JsonParser starts parsing a #JsonArray The ::error signal is emitted each time a #JsonParser encounters an error in a JSON stream. a pointer to the #GError The ::object-end signal is emitted each time the #JsonParser has successfully parsed an entire #JsonObject. the parsed #JsonObject The ::object-member signal is emitted each time the #JsonParser has successfully parsed a single member of a #JsonObject. The object and member are passed to the signal handlers. a #JsonObject the name of the newly parsed member The ::object-start signal is emitted each time the #JsonParser starts parsing a #JsonObject. The ::parse-end signal is emitted when the parser successfully finished parsing a JSON data stream The ::parse-start signal is emitted when the parser began parsing a JSON data stream. #JsonParser class. Error enumeration for #JsonParser This enumeration can be extended at later date The <structname>JsonReader</structname> structure contains only private data and should only be accessed using the provided API Creates a new #JsonReader. You can use this object to read the contents of the JSON tree starting from @node release the allocated resources when done the newly created #JsonReader. Use g_object_unref() to a #JsonNode, or %NULL Counts the elements of the current position, if @reader is positioned on an array the #JsonReader is set in an error state the number of elements, or -1. In case of failure Counts the members of the current position, if @reader is positioned on an object the #JsonReader is set in an error state the number of members, or -1. In case of failure Moves the cursor back to the previous node after being positioned inside an array This function resets the error state of @reader, if any was set Moves the cursor back to the previous node after being positioned inside an object This function resets the error state of @reader, if any was set Retrieves the boolean value of the current position of @reader the boolean value Retrieves the floating point value of the current position of @reader the floating point value Retrieves the #GError currently set on @reader, if the #JsonReader is in error state the pointer to the error, or %NULL Retrieves the integer value of the current position of @reader the integer value Checks whether the value of the current position of @reader is 'null' %TRUE if 'null' is set, and %FALSE otherwise Retrieves the string value of the current position of @reader the string value Retrieves the #JsonNode of the current position of @reader is owned by the #JsonReader and it should not be modified or freed directly a #JsonNode, or %NULL. The returned node Checks whether the @reader is currently on an array otherwise %TRUE if the #JsonReader is on an array, and %FALSE Checks whether the @reader is currently on an object otherwise %TRUE if the #JsonReader is on an object, and %FALSE Checks whether the @reader is currently on a value otherwise %TRUE if the #JsonReader is on a value, and %FALSE Advances the cursor of @reader to the element @index_ of array at the current position. You can use the json_reader_get_value* family of functions to retrieve the value of the element; for instance: |[ json_reader_read_element (reader, 0); int_value = json_reader_get_int_value (reader); ]| After reading the value, json_reader_end_element() should be called to reposition the cursor inside the #JsonReader, e.g.: |[ json_reader_read_element (reader, 1); str_value = json_reader_get_string_value (reader); json_reader_end_element (reader); json_reader_read_element (reader, 2); str_value = json_reader_get_string_value (reader); json_reader_end_element (reader); ]| If @reader is not currently on an array, or if the @index_ is bigger than the size of the array, the #JsonReader will be put in an error state until json_reader_end_element() is called. %TRUE on success, and %FALSE otherwise the index of the element Advances the cursor of @reader to the @member_name of the object at the current position. You can use the json_reader_get_value* family of functions to retrieve the value of the member; for instance: |[ json_reader_read_member (reader, "width"); width = json_reader_get_int_value (reader); ]| After reading the value, json_reader_end_member() should be called to reposition the cursor inside the #JsonReader, e.g.: |[ json_reader_read_member (reader, "author"); author = json_reader_get_string_value (reader); json_reader_end_element (reader); json_reader_read_element (reader, "title"); title = json_reader_get_string_value (reader); json_reader_end_element (reader); ]| If @reader is not currently on an object, or if the @member_name is not defined in the object, the #JsonReader will be put in an error state until json_reader_end_member() is called. %TRUE on success, and %FALSE otherwise the name of the member to read Sets the root #JsonNode to be read by @reader. The @reader will take a copy of @root If another #JsonNode is currently set as root, it will be replaced. a #JsonNode The root of the JSON tree that the #JsonReader should read. The <structname>JsonReaderClass</structname> structure contains only private data Error codes enumeration for #JsonReader errors Asks a #JsonSerializable implementation to deserialize the property contained inside @property_node into @value. %TRUE if the property was successfully deserialized. the name of the property a pointer to an uninitialized #GValue a #GParamSpec a #JsonNode containing the serialized property Asks a #JsonSerializable implementation to serialize a #GObject property into a #JsonNode object. a #JsonNode containing the serialized property the name of the property the value of the property a #GParamSpec Calls the default implementation of the #JsonSerializable deserialize_property() virtual function This function can be used inside a custom implementation of the deserialize_property() virtual function in lieu of: |[ JsonSerializable *iface; gboolean res; iface = g_type_default_interface_peek (JSON_TYPE_SERIALIZABLE); res = iface->deserialize_property (serializable, property_name, value, pspec, property_node); ]| %TRUE if the property was successfully deserialized. the name of the property a pointer to an uninitialized #GValue a #GParamSpec a #JsonNode containing the serialized property Calls the default implementation of the #JsonSerializable serialize_property() virtual function This function can be used inside a custom implementation of the serialize_property() virtual function in lieu of: |[ JsonSerializable *iface; JsonNode *node; iface = g_type_default_interface_peek (JSON_TYPE_SERIALIZABLE); node = iface->serialize_property (serializable, property_name, value, pspec); ]| property a #JsonNode containing the serialized the name of the property the value of the property a #GParamSpec Asks a #JsonSerializable implementation to deserialize the property contained inside @property_node into @value. %TRUE if the property was successfully deserialized. the name of the property a pointer to an uninitialized #GValue a #GParamSpec a #JsonNode containing the serialized property Asks a #JsonSerializable implementation to serialize a #GObject property into a #JsonNode object. a #JsonNode containing the serialized property the name of the property the value of the property a #GParamSpec Interface that allows serializing and deserializing #GObject<!-- -->s with properties storing complex data types. The json_serialize_gobject() function will check if the passed #GObject implements this interface, so it can also be used to override the default property serialization sequence. a #JsonNode containing the serialized property the name of the property the value of the property a #GParamSpec %TRUE if the property was successfully deserialized. the name of the property a pointer to an uninitialized #GValue a #GParamSpec a #JsonNode containing the serialized property Checks whether it is possible to deserialize a #GBoxed of type @gboxed_type from a #JsonNode of type @node_type %TRUE if the type can be deserialized, %FALSE otherwise a boxed type a #JsonNode type Checks whether it is possible to serialize a #GBoxed of type @gboxed_type into a #JsonNode. The type of the #JsonNode is placed inside @node_type if the function returns %TRUE and it's undefined otherwise. and %FALSE otherwise. %TRUE if the type can be serialized, a boxed type the #JsonNode type to which the boxed type can be serialized into Deserializes @node into a #GBoxed of @gboxed_type g_boxed_free() to release the resources allocated by this function the newly allocated #GBoxed. Use a boxed type a #JsonNode Registers a deserialization function for a #GBoxed of type @gboxed_type from a #JsonNode of type @node_type a boxed type a node type deserialization function for @boxed_type from a #JsonNode of type @node_type Registers a serialization function for a #GBoxed of type @gboxed_type to a #JsonNode of type @node_type a boxed type a node type serialization function for @boxed_type into a #JsonNode of type @node_type Serializes @boxed, a pointer to a #GBoxed of type @gboxed_type, into a #JsonNode boxed type, or %NULL if serialization either failed or was not possible a #JsonNode with the serialization of the a boxed type a pointer to a #GBoxed of type @gboxed_type Deserializes a JSON data stream and creates the corresponding #GObject class. If @gtype implements the #JsonSerializableIface interface, 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. a #GObject or %NULL the #GType of object to construct a JSON data stream length of the data stream Creates a new #GObject of type @gtype, and constructs it using the members of the passed #JsonObject instance. Use g_object_unref() to free the resources allocated by this function The newly created #GObject the type of the #GObject to create a #JsonNode of type %JSON_NODE_OBJECT describing the instance of type @gtype Deserializes a JSON data stream and creates the corresponding #GObject class. If @gtype implements the #JsonSerializableIface interface, 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. a #GObject or %NULL the #GType of object to construct a JSON data stream length of the data stream, or -1 if it is NUL-terminated Creates a #JsonNode representing the passed #GObject instance. Each member of the returned JSON object will map to a property of the #GObject of type %JSON_NODE_OBJECT. Use json_node_free() to free the resources allocated by this function the newly created #JsonNode a #GObject Serializes a #GObject into a JSON data stream, iterating recursively over each property. If @gobject implements the #JsonSerializableIface interface, 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. a JSON data stream representing the passed #GObject a #GObject return value for the length of the buffer, or %NULL Serializes a #GObject into a JSON data stream. If @gobject implements the #JsonSerializableIface interface, 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. a JSON data stream representing the passed #GObject a #GObject return value for the length of the buffer, or %NULL