JsonObject

## JsonObject JsonObject — a JSON object representation |

## Synopsis

                        JsonObject;
    JsonObject*         json_object_new                     (void);
    JsonObject*         json_object_ref                     (JsonObject *object);
    void                json_object_unref                   (JsonObject *object);

    void                json_object_add_member              (JsonObject *object,
                                                             const gchar *member_name,
                                                             JsonNode *node);
    gboolean            json_object_has_member              (JsonObject *object,
                                                             const gchar *member_name);
    JsonNode*           json_object_get_member              (JsonObject *object,
                                                             const gchar *member_name);
    JsonNode*           json_object_dup_member              (JsonObject *object,
                                                             const gchar *member_name);
    GList*              json_object_get_members             (JsonObject *object);
    GList*              json_object_get_values              (JsonObject *object);
    guint               json_object_get_size                (JsonObject *object);
    void                json_object_remove_member           (JsonObject *object,
                                                             const gchar *member_name);

## Description

JsonArray is the representation of the object type inside JSON. It contains JsonNodes, which may contain fundamental types, arrays or other objects. Each member of an object is accessed using its name. Please note that the member names are normalized internally before being used; every delimiter matching the `G_STR_DELIMITER` macro will be transformed into an underscore, so for instance "member-name" and "member_name" are equivalent for a JsonObject.

Since objects can be expensive, they are reference counted. You can control the lifetime of a JsonObject using `json_object_ref()` and `json_object_unref()`.

To add a member with a given name, use `json_object_add_member()`. To extract a member with a given name, use `json_object_get_member()`. To retrieve the list of members, use `json_object_get_members()`. To retrieve the size of the object (that is, the number of members it has), use `json_object_get_size()`.

## Details

### JsonObject

    typedef struct _JsonObject JsonObject;

A JSON object type. The contents of the JsonObject structure are private and should only be accessed by the provided API

### json_object_new ()

    JsonObject*         json_object_new                     (void);

Creates a new JsonObject, an JSON object type representation.

Returns : | the newly created JsonObject

### json_object_ref ()

    JsonObject*         json_object_ref                     (JsonObject *object);

Increase by one the reference count of a JsonObject.

`object` : | a JsonObject
Returns : | the passed JsonObject, with the reference count increased by one.

### json_object_unref ()

    void                json_object_unref                   (JsonObject *object);

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.

`object` : | a JsonObject

### json_object_add_member ()

    void                json_object_add_member              (JsonObject *object,
                                                             const gchar *member_name,
                                                             JsonNode *node);

Adds a member named `member_name` and containing `node` into a JsonObject. The object will take ownership of the JsonNode.

`object` : | a JsonObject
`member_name` : | the name of the member
`node` : | the value of the member

### json_object_has_member ()

    gboolean            json_object_has_member              (JsonObject *object,
                                                             const gchar *member_name);

Checks whether `object` has a member named `member_name`.

`object` : | a JsonObject
`member_name` : | the name of a JSON object member
Returns : | `TRUE` if the JSON object has the requested member

### json_object_get_member ()

    JsonNode*           json_object_get_member              (JsonObject *object,
                                                             const gchar *member_name);

Retrieves the JsonNode containing the value of `member_name` inside a JsonObject.

`object` : | a JsonObject
`member_name` : | the name of the JSON object member to access
Returns : | a pointer to the node for the requested object member, or `NULL`

### json_object_dup_member ()

    JsonNode*           json_object_dup_member              (JsonObject *object,
                                                             const gchar *member_name);

Retrieves a copy of the JsonNode containing the value of `member_name` inside a JsonObject

`object` : | a JsonObject
`member_name` : | the name of the JSON object member to access
Returns : | a copy of the node for the requested object member or `NULL`. Use `json_node_free()` when done.

Since 0.6

### json_object_get_members ()

    GList*              json_object_get_members             (JsonObject *object);

Retrieves all the names of the members of a JsonObject. You can obtain the value for each member using `json_object_get_member()`.

`object` : | a JsonObject
Returns : | a GList 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.

### json_object_get_values ()

    GList*              json_object_get_values              (JsonObject *object);

Retrieves all the values of the members of a JsonObject.

`object` : | a JsonObject
Returns : | a GList of JsonNodes. 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.

### json_object_get_size ()

    guint               json_object_get_size                (JsonObject *object);

Retrieves the number of members of a JsonObject.

`object` : | a JsonObject
Returns : | the number of members

### json_object_remove_member ()

    void                json_object_remove_member           (JsonObject *object,
                                                             const gchar *member_name);

Removes `member_name` from `object`, freeing its allocated resources.

`object` : | a JsonObject
`member_name` : | the name of the member to remove