![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Typedefs | |
| typedef struct N_JSON | N_JSON |
| Opaque JSON node (a cJSON node under the hood). | |
Functions | |
| N_JSON * | n_json_array_at (const N_JSON *arr, size_t i) |
| Get an array element by index. | |
| size_t | n_json_array_size (const N_JSON *arr) |
| Number of elements in an array node. | |
| const char * | n_json_as_string (const N_JSON *v, const char *dflt) |
| Get the string value of a node itself (e.g. | |
| int | n_json_bool (const N_JSON *obj, const char *key, int dflt) |
| Get a boolean member, or a default when absent/not a boolean. | |
| void | n_json_free (N_JSON **root) |
| Free a JSON tree and NULL the caller's pointer. | |
| N_JSON * | n_json_get (const N_JSON *obj, const char *key) |
| Get a child member of an object by key (case-sensitive). | |
| long | n_json_int (const N_JSON *obj, const char *key, long dflt) |
| Get a numeric member as a long, or a default when absent/not a number. | |
| int | n_json_is_array (const N_JSON *v) |
| Report whether a node is a JSON array. | |
| int | n_json_is_object (const N_JSON *v) |
| Report whether a node is a JSON object. | |
| N_JSON * | n_json_parse (const char *text) |
| Parse a JSON document from a NUL-terminated string. | |
| N_JSON * | n_json_parse_file (const char *path) |
| Parse a JSON document from a file. | |
| const char * | n_json_string (const N_JSON *obj, const char *key, const char *dflt) |
| Get a string member, or a default when absent/not a string. | |
| char * | n_json_string_dup (const N_JSON *obj, const char *key) |
| Duplicate a string member (caller frees), or NULL when absent. | |
Get an array element by index.
| arr | The array node, or NULL. |
| i | Zero-based index. |
Definition at line 118 of file n_json.c.
References AS_CONST_CJSON, and AS_NJSON.
Referenced by main().
Here is the caller graph for this function:| size_t n_json_array_size | ( | const N_JSON * | arr | ) |
Number of elements in an array node.
| arr | The array node, or NULL. |
Definition at line 112 of file n_json.c.
References AS_CONST_CJSON.
Referenced by main().
Here is the caller graph for this function:| const char * n_json_as_string | ( | const N_JSON * | v, |
| const char * | dflt | ||
| ) |
Get the string value of a node itself (e.g.
an array element).
| v | The node, or NULL. |
| dflt | Value returned when v is not a string. |
dflt. Definition at line 124 of file n_json.c.
References AS_CONST_CJSON.
Referenced by main().
Here is the caller graph for this function:| int n_json_bool | ( | const N_JSON * | obj, |
| const char * | key, | ||
| int | dflt | ||
| ) |
Get a boolean member, or a default when absent/not a boolean.
| obj | The object node, or NULL. |
| key | The member name. |
| dflt | Value returned when the member is missing or not a boolean. |
dflt. Definition at line 97 of file n_json.c.
References AS_CONST_CJSON, and key.
Referenced by main().
Here is the caller graph for this function:| void n_json_free | ( | N_JSON ** | root | ) |
Get a child member of an object by key (case-sensitive).
| obj | The object node, or NULL. |
| key | The member name. NULL returns NULL. |
Definition at line 72 of file n_json.c.
References AS_CONST_CJSON, AS_NJSON, and key.
Referenced by main().
Here is the caller graph for this function:| long n_json_int | ( | const N_JSON * | obj, |
| const char * | key, | ||
| long | dflt | ||
| ) |
Get a numeric member as a long, or a default when absent/not a number.
| obj | The object node, or NULL. |
| key | The member name. |
| dflt | Value returned when the member is missing or not a number. |
dflt. Definition at line 90 of file n_json.c.
References AS_CONST_CJSON, and key.
Referenced by main().
Here is the caller graph for this function:| int n_json_is_array | ( | const N_JSON * | v | ) |
Report whether a node is a JSON array.
| v | The node, or NULL. |
v is an array, 0 otherwise. Definition at line 104 of file n_json.c.
References AS_CONST_CJSON.
Referenced by main().
Here is the caller graph for this function:| int n_json_is_object | ( | const N_JSON * | v | ) |
Report whether a node is a JSON object.
| v | The node, or NULL. |
v is an object, 0 otherwise. Definition at line 108 of file n_json.c.
References AS_CONST_CJSON.
Referenced by main().
Here is the caller graph for this function:| N_JSON * n_json_parse | ( | const char * | text | ) |
Parse a JSON document from a NUL-terminated string.
| text | The JSON text. NULL returns NULL. |
Definition at line 43 of file n_json.c.
References AS_NJSON.
Referenced by main().
Here is the caller graph for this function:| N_JSON * n_json_parse_file | ( | const char * | path | ) |
Parse a JSON document from a file.
| path | Path to the JSON file. NULL returns NULL. |
Definition at line 49 of file n_json.c.
References AS_NJSON, N_STR::data, file_to_nstr(), and free_nstr.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| const char * n_json_string | ( | const N_JSON * | obj, |
| const char * | key, | ||
| const char * | dflt | ||
| ) |
Get a string member, or a default when absent/not a string.
| obj | The object node, or NULL. |
| key | The member name. |
| dflt | Value returned when the member is missing or not a string. |
dflt. Definition at line 78 of file n_json.c.
References AS_CONST_CJSON, and key.
Referenced by main(), and n_json_string_dup().
Here is the caller graph for this function:| char * n_json_string_dup | ( | const N_JSON * | obj, |
| const char * | key | ||
| ) |
Duplicate a string member (caller frees), or NULL when absent.
| obj | The object node, or NULL. |
| key | The member name. |
Definition at line 85 of file n_json.c.
References key, and n_json_string().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function: