jkii
|
This is a file defining Kii JSON APIs. More...
#include <jsmn.h>
Go to the source code of this file.
Data Structures | |
struct | jkii_resource_t |
struct | jkii_field_t |
Typedefs | |
typedef jsmntok_t | jkii_token_t |
typedef struct jkii_resource_t | jkii_resource_t |
typedef jkii_resource_t *(* | JKII_CB_RESOURCE_ALLOC) (size_t required_size) |
typedef void(* | JKII_CB_RESOURCE_FREE) (jkii_resource_t *resource) |
typedef enum jkii_boolean_t | jkii_boolean_t |
typedef enum jkii_parse_err_t | jkii_parse_err_t |
typedef enum jkii_field_err_t | jkii_field_err_t |
typedef enum jkii_field_type_t | jkii_field_type_t |
typedef struct jkii_field_t | jkii_field_t |
Functions | |
jkii_parse_err_t | jkii_parse (const char *json_string, size_t json_string_len, jkii_field_t *fields, jkii_resource_t *resource) |
jkii_parse_err_t | jkii_parse_with_allocator (const char *json_string, size_t json_string_len, jkii_field_t *fields, JKII_CB_RESOURCE_ALLOC cb_alloc, JKII_CB_RESOURCE_FREE cb_free) |
This is a file defining Kii JSON APIs.
typedef enum jkii_boolean_t jkii_boolean_t |
Boolean type
typedef jkii_resource_t*(* JKII_CB_RESOURCE_ALLOC) (size_t required_size) |
Resource allocator for jkii_resource_t.
[in] | required_size | required token size. |
typedef void(* JKII_CB_RESOURCE_FREE) (jkii_resource_t *resource) |
typedef enum jkii_field_err_t jkii_field_err_t |
Field parsing result. Assigned to jkii_field_t::result.
typedef struct jkii_field_t jkii_field_t |
JSON parsed field data.
Input of jkii_parse(jkii_t*, const char*, size_t, jkii_field_t*).
Array of jkii_field_t is passed to jkii_parse(jkii_t*, const char*, size_t, jkii_field_t*).
End point of the array is specified by jkii_field_t::name and jkii_field_t::path. If both of jkii_field_t::name and jkii_field_t::path are NULL, jkii_parse(jkii_t*, const char*, size_t, jkii_field_t*) consider that it is the end point of the passed array.
typedef enum jkii_field_type_t jkii_field_type_t |
Type of parsed JSON field. This value is assigned to jkii_field_t::type.
typedef enum jkii_parse_err_t jkii_parse_err_t |
Return value of jkii_parse(jkii_t*, const char*, size_t, jkii_field_t*)
typedef struct jkii_resource_t jkii_resource_t |
Resource used by KII JSON library. Fields of this struct determines max number of tokens inside json can be parsed.
typedef jsmntok_t jkii_token_t |
JSON token data to parse JSON string.
enum jkii_boolean_t |
enum jkii_field_err_t |
Field parsing result. Assigned to jkii_field_t::result.
Enumerator | |
---|---|
JKII_FIELD_ERR_OK | Field parsing is success. |
JKII_FIELD_ERR_TYPE_MISMATCH | Type of field specified jkii_field_t::type is mismatch. |
JKII_FIELD_ERR_NOT_FOUND | Field specified by jkii_field_t::name is not found. |
JKII_FIELD_ERR_COPY | Coping string to jkii_field_t::field_copy::string is failed. jkii_field_t::field_copy_buff_size may shorter than actual length. |
JKII_FIELD_ERR_NUM_OVERFLOW | Coping int, long or double value to jkii_field_t::field_copy::int_value, jkii_field_t::field_copy::long_value or jkii_field_t::field_copy::double_value is failed. value is overflowed. |
JKII_FIELD_ERR_NUM_UNDERFLOW | Coping int, long or double value to jkii_field_t::field_copy::int_value, jkii_field_t::field_copy::long_value or jkii_field_t::field_copy::double_value is failed. value is underflowed. |
enum jkii_field_type_t |
Type of parsed JSON field. This value is assigned to jkii_field_t::type.
Enumerator | |
---|---|
JKII_FIELD_TYPE_ANY | This value denotes any JSON types. If this value is set to jkii_field_t::type, then jkii_parse(jkii_t*, const char*, size_t, jkii_field_t*) ignore type checking. |
JKII_FIELD_TYPE_INTEGER | This values denotes an signed interger value. Maximum is INT_MAX and Minimum is INT_MIN. |
JKII_FIELD_TYPE_LONG | This values denotes an signed interger value. Maximum is LONG_MAX and Minimum is LONG_MIN. |
JKII_FIELD_TYPE_DOUBLE | This value denotes an double value. |
JKII_FIELD_TYPE_BOOLEAN | This value denotes jkii_boolean_t value. |
JKII_FIELD_TYPE_NULL | This value denotes denotes NULL value. |
JKII_FIELD_TYPE_STRING | This value denotes JSON string. |
JKII_FIELD_TYPE_OBJECT | This value denotes JSON object. |
JKII_FIELD_TYPE_ARRAY | This value denotes JSON array. |
enum jkii_parse_err_t |
Return value of jkii_parse(jkii_t*, const char*, size_t, jkii_field_t*)
Enumerator | |
---|---|
JKII_ERR_OK | JSON string is successfully parsed and all jkii_field_t variables are successfully set. i.e., all jkii_field_t type fields are JKII_FIELD_ERR_OK. |
JKII_ERR_PARTIAL | JSON string is successfully parsed but some jkii_field_t variables are failed. i.e., some jkii_field_t type fields are not JKII_FIELD_ERR_OK. |
JKII_ERR_ROOT_TYPE | JSON string is successfully parsed but type of root object type is unmatched to using function. jkii_parse(jkii_t*, const char*, size_t, jkii_field_t*) requires JSON object if JSON array is passed, then this error is returned. |
JKII_ERR_TOKENS_SHORTAGE | jkii_t::tokens is not enough to parse JSON string. |
JKII_ERR_INVALID_INPUT | JSON string is failed to parse. Passed string is not JSON string. |
JKII_ERR_ALLOCATION | Allocation failed. |
jkii_parse_err_t jkii_parse | ( | const char * | json_string, |
size_t | json_string_len, | ||
jkii_field_t * | fields, | ||
jkii_resource_t * | resource | ||
) |
Parse JSON string.
[in] | json_string | of JSON string. |
[in] | json_string_len | of JSON string. |
[in,out] | fields | of kii JSON parser. |
[in] | resource | of parser. |
jkii_parse_err_t jkii_parse_with_allocator | ( | const char * | json_string, |
size_t | json_string_len, | ||
jkii_field_t * | fields, | ||
JKII_CB_RESOURCE_ALLOC | cb_alloc, | ||
JKII_CB_RESOURCE_FREE | cb_free | ||
) |
Parse JSON string with custom memory allocator.
[in] | json_string | of JSON string. |
[in] | json_string_len | of JSON string. |
[in,out] | fields | of kii JSON parser. |
[in] | cb_alloc | allocate resource |
[in] | cb_free | free resource |