|
SGDK
A free and open development kit for the Sega Mega Drive
|
JSON implementation, based on jsmn by Serge Zaitsev. More...
Macros | |
| #define | JSMN_STATIC |
| Hides jsmn API definitions to avoid linking errors. | |
| #define | json_item(json_str, obj_tok, idx) |
Functions | |
| int | json_null_terminate (char *json_str, const jsmntok_t *obj_tok, int num_tok) |
| Add null-terminators to the input JSON string. Useful to further extract token values as null-terminated strings. | |
| bool | json_is_key (const jsmntok_t *json_tok, int obj_idx, int num_tok) |
| Determines if pointed token corresponds to a key in a key:value pair. | |
| int | json_object_next (const jsmntok_t *obj_tok, int obj_idx, int parent_idx, int num_tok) |
| Return the index of the next item. This function only works properly when specified token is of JSMN_OBJECT type. | |
| int | json_key_next (const jsmntok_t *json_tok, int obj_idx, int parent_idx, int num_tok) |
| Return the index of the next key in the current JSON level. | |
| int | json_key_search (const char *key, const char *json_str, const jsmntok_t *json_tok, int obj_idx, int parent_idx, int num_tok) |
| Search for a given key in the current JSON level. | |
| int | json_bool_get (const char *json_str, const jsmntok_t *json_tok, int obj_idx) |
| Obtains the boolean value corresponding to the indicated token. | |
JSON implementation, based on jsmn by Serge Zaitsev.
This module just adds some helper functions to jsmn to ease navigating the JSON structure and extracting values.
| #define json_item | ( | json_str, | |
| obj_tok, | |||
| idx ) |
Macro to extract the item (as string) from a token. Requires the json_str to have the null terminations added by json_null_terminate().
| int json_bool_get | ( | const char * | json_str, |
| const jsmntok_t * | json_tok, | ||
| int | obj_idx ) |
Obtains the boolean value corresponding to the indicated token.
| [in] | json_str | JSON string. |
| [in] | json_tok | JSON token array extracted from json_str. |
| [in] | obj_idx | Index of the token to analyse. |
Determines if pointed token corresponds to a key in a key:value pair.
| [in] | json_tok | JSON token array. |
| [in] | obj_idx | Index of the token to analyse. |
| [in] | num_tok | Number of tokens in json_tok. |
| int json_key_next | ( | const jsmntok_t * | json_tok, |
| int | obj_idx, | ||
| int | parent_idx, | ||
| int | num_tok ) |
Return the index of the next key in the current JSON level.
| [in] | json_tok | JSON token array. |
| [in] | obj_idx | Index of the token to analyse. |
| [in] | parent_idx | Index of the parent object or array token. |
| [in] | num_tok | Number of tokens in obj_tok. |
| int json_key_search | ( | const char * | key, |
| const char * | json_str, | ||
| const jsmntok_t * | json_tok, | ||
| int | obj_idx, | ||
| int | parent_idx, | ||
| int | num_tok ) |
Search for a given key in the current JSON level.
| [in] | key | key string to search. |
| [in] | json_str | JSON string. |
| [in] | json_tok | JSON token array. |
| [in] | obj_idx | Index of the token to analyse. |
| [in] | parent_idx | Index of the parent object or array token. |
| [in] | num_tok | Number of tokens in obj_tok. |
| int json_null_terminate | ( | char * | json_str, |
| const jsmntok_t * | obj_tok, | ||
| int | num_tok ) |
Add null-terminators to the input JSON string. Useful to further extract token values as null-terminated strings.
| [in,out] | json_str | The JSON string to add null terminators to. |
| [in] | obj_tok | Tokens extracted from json_str. |
| [in] | num_tok | Number of tokens in obj_tok. |
| int json_object_next | ( | const jsmntok_t * | obj_tok, |
| int | obj_idx, | ||
| int | parent_idx, | ||
| int | num_tok ) |
Return the index of the next item. This function only works properly when specified token is of JSMN_OBJECT type.
| [in] | obj_tok | JSON token array. |
| [in] | obj_idx | Index of the token to analyse. |
| [in] | parent_idx | Index of the parent object or array token. |
| [in] | num_tok | Number of tokens in obj_tok. |