This is a file defining Kii JSON APIs. More...
#include <jsmn.h>
Go to the source code of this file.
Classes | |
struct | kii_json_resource_t |
struct | kii_json_t |
struct | kii_json_field_t |
Typedefs | |
typedef jsmntok_t | kii_json_token_t |
typedef struct kii_json_resource_t | kii_json_resource_t |
typedef int(* | KII_JSON_RESOURCE_CB )(kii_json_resource_t *resource, size_t required_size) |
typedef struct kii_json_t | kii_json_t |
typedef enum kii_json_boolean_t | kii_json_boolean_t |
typedef enum kii_json_parse_result_t | kii_json_parse_result_t |
typedef enum kii_json_field_parse_result_t | kii_json_field_parse_result_t |
typedef enum kii_json_field_type_t | kii_json_field_type_t |
typedef struct kii_json_field_t | kii_json_field_t |
Functions | |
kii_json_parse_result_t | kii_json_read_object (kii_json_t *kii_json, const char *json_string, size_t json_string_len, kii_json_field_t *fields) |
This is a file defining Kii JSON APIs.
typedef enum kii_json_boolean_t kii_json_boolean_t |
Boolean type
Field parsing result. Assigned to kii_json_field_t::result.
typedef struct kii_json_field_t kii_json_field_t |
JSON parsed field data.
Input of kii_json_read_object(kii_json_t*, const char*, size_t, kii_json_field_t*).
Array of kii_json_field_t is passed to kii_json_read_object(kii_json_t*, const char*, size_t, kii_json_field_t*).
End point of the array is specified by kii_json_field_t::name and kii_json_field_t::path. If both of kii_json_field_t::name and kii_json_field_t::path are NULL, kii_json_read_object(kii_json_t*, const char*, size_t, kii_json_field_t*) consider that it is the end point of the passed array.
typedef enum kii_json_field_type_t kii_json_field_type_t |
Type of parsed JSON field. This value is assigned to kii_json_field_t::type.
typedef enum kii_json_parse_result_t kii_json_parse_result_t |
Return value of kii_json_read_object(kii_json_t*, const char*, size_t, kii_json_field_t*)
typedef int(* KII_JSON_RESOURCE_CB)(kii_json_resource_t *resource, size_t required_size) |
Resource allocator for kii_json_resource_t.
When parsing target JSON string requires more tokens provided by kii_json_resource_t, This function is called. You need to resize kii_json_resource_t::tokens and set new size to kii_json_resource_t::tokens_num which is greater than or equal to required_size.
If you allocate new resource, Application may need to free old resource since the library never free the given resource.
[in,out] | resource | kii json resources used by KII JSON library. |
[in] | required_size | newly required token size. |
typedef struct kii_json_resource_t kii_json_resource_t |
Resource used by KII JSON library. Fields of this struct determines max number of tokens inside json can be parsed.
typedef struct kii_json_t kii_json_t |
object manages context of kii json apis. Do not share this object and fields inside this object among the thread/tasks. library won't sync the request if the multiple threads/tasks share the resource.
typedef jsmntok_t kii_json_token_t |
JSON token data to parse JSON string.
enum kii_json_boolean_t |
Field parsing result. Assigned to kii_json_field_t::result.
Enumerator | |
---|---|
KII_JSON_FIELD_PARSE_SUCCESS |
Field parsing is success. |
KII_JSON_FIELD_PARSE_TYPE_UNMATCHED |
Type of field specified kii_json_field_t::type is unmathced. |
KII_JSON_FIELD_PARSE_NOT_FOUND |
Field specified by kii_json_field_t::name is not found. |
KII_JSON_FIELD_PARSE_COPY_FAILED |
Coping string to kii_json_field_t::field_copy::string is failed. kii_json_field_t::field_copy_buff_size may shorter than actual length. |
KII_JSON_FIELD_PARSE_COPY_OVERFLOW |
Coping int, long or double value to kii_json_field_t::field_copy::int_value, kii_json_field_t::field_copy::long_value or kii_json_field_t::field_copy::double_value is failed. value is overflowed. |
KII_JSON_FIELD_PARSE_COPY_UNDERFLOW |
Coping int, long or double value to kii_json_field_t::field_copy::int_value, kii_json_field_t::field_copy::long_value or kii_json_field_t::field_copy::double_value is failed. value is underflowed. |
Type of parsed JSON field. This value is assigned to kii_json_field_t::type.
Enumerator | |
---|---|
KII_JSON_FIELD_TYPE_ANY |
This value denotes any JSON types. If this value is set to kii_json_field_t::type, then kii_json_read_object(kii_json_t*, const char*, size_t, kii_json_field_t*) ignore type checking. |
KII_JSON_FIELD_TYPE_INTEGER |
This values denotes an signed interger value. Maximum is INT_MAX and Minimum is INT_MIN. |
KII_JSON_FIELD_TYPE_LONG |
This values denotes an signed interger value. Maximum is LONG_MAX and Minimum is LONG_MIN. |
KII_JSON_FIELD_TYPE_DOUBLE |
This value denotes an double value. |
KII_JSON_FIELD_TYPE_BOOLEAN |
This value denotes kii_json_boolean_t value. |
KII_JSON_FIELD_TYPE_NULL |
This value denotes denotes NULL value. |
KII_JSON_FIELD_TYPE_STRING |
This value denotes JSON string. |
KII_JSON_FIELD_TYPE_OBJECT |
This value denotes JSON object. |
KII_JSON_FIELD_TYPE_ARRAY |
This value denotes JSON array. |
Return value of kii_json_read_object(kii_json_t*, const char*, size_t, kii_json_field_t*)
Enumerator | |
---|---|
KII_JSON_PARSE_SUCCESS |
JSON string is successfully parsed and all kii_json_field_t variables are successfully set. i.e., all kii_json_field_t type fields are KII_JSON_FIELD_PARSE_SUCCESS. |
KII_JSON_PARSE_PARTIAL_SUCCESS |
JSON string is successfully parsed but some kii_json_field_t variables are failed. i.e., some kii_json_field_t type fields are not KII_JSON_FIELD_PARSE_SUCCESS. |
KII_JSON_PARSE_ROOT_TYPE_ERROR |
JSON string is successfully parsed but type of root object type is unmatched to using function. kii_json_read_object(kii_json_t*, const char*, size_t, kii_json_field_t*) requires JSON object if JSON array is passed, then this error is returned. |
KII_JSON_PARSE_SHORTAGE_TOKENS |
kii_json_t::tokens is not enough to parse JSON string. |
KII_JSON_PARSE_INVALID_INPUT |
JSON string is failed to parse. Passed string is not JSON string. |
kii_json_parse_result_t kii_json_read_object | ( | kii_json_t * | kii_json, |
const char * | json_string, | ||
size_t | json_string_len, | ||
kii_json_field_t * | fields | ||
) |
parse JSON string as JSON object.
[in] | kii | json instance. |
[in] | pointer | of JSON string. |
[in] | length | of JSON string. |
[in,out] | field | of kii JSON parser. |