JSON Utility Functions

JSON Utility Functions — JSON related utility functions

Functions

Includes

#include <font-manager-json.h>

Description

Helper functions to make working with JSON data easier.

Functions

font_manager_compare_json_int_member ()

gint
font_manager_compare_json_int_member (const gchar *member_name,
                                      JsonObject *a,
                                      JsonObject *b);

Parameters

member_name

name of member to compare

 

a

JsonObject

 

b

JsonObject

 

Returns

An integer less than, equal to, or greater than zero if member from a is <, == or > than member from b


font_manager_compare_json_string_member ()

gint
font_manager_compare_json_string_member
                               (const gchar *member_name,
                                JsonObject *a,
                                JsonObject *b);

Parameters

member_name

name of member to compare

 

a

JsonObject

 

b

JsonObject

 

Returns

An integer less than, equal to, or greater than zero if member from a is <, == or > than member from b


font_manager_compare_json_font_node ()

gint
font_manager_compare_json_font_node (JsonNode *node_a,
                                     JsonNode *node_b);

Parameters

node_a

JsonNode containing a font description

 

node_b

JsonNode containing a font description

 

Returns

An integer less than, equal to, or greater than zero, if font a is <, == or > than font b


font_manager_print_json_array ()

gchar *
font_manager_print_json_array (JsonArray *json_arr,
                               gboolean pretty);

Convenience function which simply wraps json_to_string to allow direct conversion of a JsonArray to string. Equivalent to creating a JsonNode, then setting the given array inside the node and calling json_to_string on the node.

Parameters

json_arr

a JsonArray

 

pretty

whether the output should be prettyfied for printing

 

Returns

A newly allocated buffer holding a JSON data stream. The returned string should be freed with g_free() when no longer needed.

[transfer full]


font_manager_print_json_object ()

gchar *
font_manager_print_json_object (JsonObject *json_obj,
                                gboolean pretty);

Convenience function which simply wraps json_to_string to allow direct conversion of a JsonObject to string. Equivalent to creating a JsonNode, then setting the given object inside the node and calling json_to_string on the node.

Parameters

json_obj

a JsonObject

 

pretty

whether the output should be prettyfied for printing

 

Returns

A newly allocated buffer holding a JSON data stream. The returned string should be freed with g_free() when no longer needed.

[transfer full]


font_manager_write_json_file ()

gboolean
font_manager_write_json_file (JsonNode *root,
                              const gchar *filepath,
                              gboolean pretty);

Parameters

root

JsonNode to use as root

 

filepath

filepath to write root to

 

pretty

whether the generated string should be pretty printed

 

Returns

TRUE if file was written successfully


font_manager_load_json_file ()

JsonNode *
font_manager_load_json_file (const gchar *filepath);

Parameters

filepath

filepath to a valid json file

 

Returns

JsonNode or NULL if file failed to load.

[transfer full][nullable]


font_manager_str_list_to_json_array ()

JsonArray *
font_manager_str_list_to_json_array (GList *slist);

Parameters

slist

a GList containing only strings.

[element-type utf8]

Returns

A newly created JsonArray.

[transfer full]