Utility API

Utility API — Various utility functions

Synopsis

#include <json-glib/json-glib.h>

JsonNode *          json_from_string                    (const char *str,
                                                         GError **error);
char *              json_to_string                      (JsonNode *node,
                                                         gboolean pretty);

Description

Various utility functions.

Details

json_from_string ()

JsonNode *          json_from_string                    (const char *str,
                                                         GError **error);

Parses the string in str and returns a JsonNode representing the JSON tree.

In case of parsing error, this function returns NULL and sets error appropriately.

str :

a valid UTF-8 string containing JSON data

error :

return location for a GError

Returns :

a JsonNode, or NULL. [transfer full]

Since 1.2


json_to_string ()

char *              json_to_string                      (JsonNode *node,
                                                         gboolean pretty);

Generates a stringified JSON representation of the contents of the passed node.

node :

a JsonNode

pretty :

whether the output should be prettyfied for printing

Returns :

the string representation of the JsonNode. [transfer full]

Since 1.2