Json utility module implementation file. More...
#include "cJSON/cJSON.h"
#include "mcl_core/mcl_json_util.h"
#include "json_util.h"
#include "string_util.h"
#include "mcl_core/mcl_assert.h"
#include "mcl_core/mcl_memory.h"
Go to the source code of this file.
Variables | |
static cJSON_Hooks | cjson_hooks |
Json utility module implementation file.
Definition in file json_util.c.
|
static |
Definition at line 926 of file json_util.c.
References json_util_get_object_item(), MCL_INVALID_PARAMETER, MCL_JSON_NAME_DUPLICATION, MCL_JSON_NON_EXISTING_CHILD, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by json_util_add_double(), and json_util_add_uint().
mcl_error_t json_util_add_bool | ( | mcl_json_t * | root, |
const char * | object_name, | ||
const mcl_bool_t | bool_value | ||
) |
This function adds bool_value
to root
which can be object or array.
[in] | root | Root json. It can be object or array. |
[in] | object_name | Name of the bool value which is going to be added to root . |
[in] | bool_value | Bool value to be added to root . |
object_name
is already used in root
as object name. root
type is array and object_name
is not null, or root
type is object and object_name
is null. Definition at line 392 of file json_util.c.
References json_util_get_object_item(), MCL_INVALID_PARAMETER, MCL_JSON_NAME_DUPLICATION, MCL_JSON_NON_EXISTING_CHILD, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by mcl_json_util_add_bool().
mcl_error_t json_util_add_double | ( | mcl_json_t * | root, |
const char * | object_name, | ||
const double | number | ||
) |
This function adds double number to root
which can be object or array.
[in] | root | Root json. It can be object or array. |
[in] | object_name | Name of the name/value pair which is going to be added to root . |
[in] | number | Value of the name/value pair which is going to be added to root . |
object_name
is already used in root
as object name. root
type is array and object_name
is not null, or root
type is object and object_name
is null. Definition at line 364 of file json_util.c.
References _add_number(), MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by _create_self_issued_jwt_payload(), and mcl_json_util_add_double().
void json_util_add_item_to_array | ( | mcl_json_t * | root, |
mcl_json_t * | object | ||
) |
This function adds object
to root
array.
[in] | root | Root json array. |
[in] | object | object which is going to be added to root array. |
Definition at line 554 of file json_util.c.
References MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by _add_key_to_keys_array(), and mcl_json_util_add_item_to_array().
mcl_error_t json_util_add_null | ( | mcl_json_t * | root, |
const char * | object_name | ||
) |
This function adds null to root
which can be object or array.
[in] | root | Root json. It can be object or array. |
[in] | object_name | Name of the null value which is going to be added to root . |
object_name
is already used in root
as object name. root
type is array and object_name
is not null, or root
type is object and object_name
is null. Definition at line 455 of file json_util.c.
References json_util_get_object_item(), MCL_INVALID_PARAMETER, MCL_JSON_NAME_DUPLICATION, MCL_JSON_NON_EXISTING_CHILD, MCL_NULL, MCL_OK, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by mcl_json_util_add_null().
mcl_error_t json_util_add_object | ( | mcl_json_t * | root, |
const char * | object_name, | ||
mcl_json_t * | object | ||
) |
This function adds object
to root
.
[in] | root | Root json object. |
[in] | object_name | Name of object which is going to be going to be added to root . |
[in] | object | object which is going to be added to root . |
object_name
is already used in root
as object name. Definition at line 512 of file json_util.c.
References json_util_get_object_item(), MCL_JSON_NAME_DUPLICATION, MCL_JSON_NON_EXISTING_CHILD, MCL_NULL, MCL_OK, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by mcl_json_util_add_object().
mcl_error_t json_util_add_string | ( | mcl_json_t * | root, |
const char * | object_name, | ||
const char * | object_value | ||
) |
This function adds string to root
which can be object or array.
root
is array, object_name
must be null.[in] | root | Root json. It can be object or array. |
[in] | object_name | Name of the name/value pair which is going to be added to root . |
[in] | object_value | Value of the name/value pair which is going to be added to root . |
object_name
is already used in root
as object name. root
type is array and object_name
is not null, or root
type is object and object_name
is null. Definition at line 273 of file json_util.c.
References json_util_get_object_item(), MCL_INVALID_PARAMETER, MCL_JSON_NAME_DUPLICATION, MCL_JSON_NON_EXISTING_CHILD, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by _add_jwks(), _add_schema_to_jwt(), _compose_rsa_key_rotation_json(), _create_self_issued_jwt_header(), _create_self_issued_jwt_payload(), and mcl_json_util_add_string().
mcl_error_t json_util_add_uint | ( | mcl_json_t * | root, |
const char * | object_name, | ||
const mcl_size_t | number | ||
) |
This function adds integer number to root
which can be object or array.
root
is array, object_name
must be null.[in] | root | Root json. It can be object or array. |
[in] | object_name | Name of the name/value pair which is going to be added to root . |
[in] | number | Value of the name/value pair which is going to be added to root . |
object_name
is already used in root
as object name. root
type is array and object_name
is not null, or root
type is object and object_name
is null. Definition at line 336 of file json_util.c.
References _add_number(), MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by mcl_json_util_add_uint().
void json_util_destroy | ( | mcl_json_t ** | root | ) |
This function destroys root
.
root
is destroyed, all child json objects in root
are also destroyed.[out] | root | Root json object. |
Definition at line 913 of file json_util.c.
References MCL_NULL, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by _compose_rsa_key_rotation_json(), _compose_rsa_onboarding_json(), _create_self_issued_jwt_header(), _create_self_issued_jwt_payload(), _process_registration_response_rsa_3072(), _process_registration_response_shared_secret(), core_processor_get_access_token(), jwt_destroy(), and mcl_json_util_destroy().
mcl_error_t json_util_duplicate | ( | const mcl_json_t * | source_json, |
mcl_json_t ** | duplicated_json | ||
) |
This function duplicates source_json
as duplicated_json
.
[in] | source_json | Json object to be duplicated. |
[out] | duplicated_json | Duplicated json from source_json . |
Definition at line 887 of file json_util.c.
References MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_TRUE, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by mcl_json_util_duplicate().
mcl_error_t json_util_get_array_item | ( | mcl_json_t * | array, |
int | index, | ||
mcl_json_t ** | item | ||
) |
This function gets the item at given index from array
.
[in] | array | Array json object. |
[in] | index | Index of the item to get from array . |
[out] | item | Result json object item. |
index
is out of range. array
is not a json array. Definition at line 153 of file json_util.c.
References MCL_INVALID_PARAMETER, MCL_JSON_TYPE_MISMATCH, MCL_NULL, MCL_OK, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by mcl_json_util_get_array_item().
mcl_error_t json_util_get_array_size | ( | mcl_json_t * | array, |
mcl_size_t * | size | ||
) |
This function returns the size of array
.
[in] | array | Array json object. |
[out] | size | Size of array . |
array
is not a json array. Definition at line 192 of file json_util.c.
References MCL_JSON_TYPE_MISMATCH, MCL_OK, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by mcl_json_util_get_array_size().
mcl_error_t json_util_get_bool_value | ( | mcl_json_t * | json, |
mcl_bool_t * | bool_value | ||
) |
This function gets the boolean value of a given json object.
[in] | json | Json object to get the value. |
[out] | bool_value | Value of json . |
Definition at line 716 of file json_util.c.
References MCL_FALSE, MCL_JSON_TYPE_MISMATCH, MCL_OK, MCL_TRUE, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by mcl_json_util_get_bool_value().
mcl_error_t json_util_get_double_value | ( | mcl_json_t * | json, |
double * | double_value | ||
) |
This function gets the double value of a given json object.
[in] | json | Json object to get the value. |
[out] | double_value | Value of json . |
Definition at line 683 of file json_util.c.
References MCL_JSON_TYPE_MISMATCH, MCL_OK, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by mcl_json_util_get_double_value().
mcl_error_t json_util_get_number_value | ( | mcl_json_t * | json, |
mcl_int32_t * | number_value | ||
) |
This function gets the integer value of a given json object.
[in] | json | Json object to get the value. |
[out] | number_value | Value of json . |
Definition at line 650 of file json_util.c.
References MCL_JSON_TYPE_MISMATCH, MCL_OK, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by mcl_json_util_get_number_value().
mcl_error_t json_util_get_object_item | ( | mcl_json_t * | json_parent, |
const char * | child_name, | ||
mcl_json_t ** | json_child | ||
) |
This function gets the value of json_child
object, when the child_name
in json_parent
object is given.
[in] | json_parent | Root json object of json_child . |
[in] | child_name | Name of the json_child object. |
[out] | json_child | The json object which is going to be received. New memory space will be allocated for this parameter. Ownership passed to caller. Caller must free the space of json_child with MCL_FREE(*json_child). |
json_child
doesn't exist in json_parent
. Definition at line 581 of file json_util.c.
References MCL_JSON_NON_EXISTING_CHILD, MCL_NULL, MCL_OK, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by _add_number(), _process_registration_response_rsa_3072(), _process_registration_response_shared_secret(), core_processor_get_access_token(), json_util_add_bool(), json_util_add_null(), json_util_add_object(), json_util_add_string(), json_util_start_array(), json_util_start_object(), and mcl_json_util_get_object_item().
mcl_error_t json_util_get_string | ( | mcl_json_t * | json, |
char ** | string_value | ||
) |
This function gets the string value of a given json object.
[in] | json | Json object to get the value. |
[out] | string_value | String value of json . |
Definition at line 754 of file json_util.c.
References MCL_JSON_TYPE_MISMATCH, MCL_MALLOC, MCL_NULL, MCL_NULL_CHAR_SIZE, MCL_OK, MCL_OUT_OF_MEMORY, MCL_VERBOSE_ENTRY, MCL_VERBOSE_LEAVE, string_util_memcpy(), and string_util_strlen().
Referenced by _process_registration_response_rsa_3072(), _process_registration_response_shared_secret(), core_processor_get_access_token(), and mcl_json_util_get_string().
mcl_bool_t json_util_has_child | ( | mcl_json_t * | root | ) |
This function checks whether root object has child object or not.
[in] | root | Json object which is going to be checked whether it has child or not. |
Definition at line 617 of file json_util.c.
References MCL_FALSE, MCL_NULL, MCL_TRUE, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by mcl_json_util_has_child().
mcl_error_t json_util_initialize | ( | E_MCL_JSON_TYPE | json_type, |
mcl_json_t ** | root | ||
) |
This function initializes the given root
json.
[in] | json_type | Type of the json. |
[out] | root | Root json. |
Definition at line 57 of file json_util.c.
References MCL_JSON_ARRAY, MCL_JSON_OBJECT, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_VERBOSE, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by _add_key_to_keys_array(), _compose_rsa_key_rotation_json(), _compose_rsa_onboarding_json(), _create_self_issued_jwt_header(), _create_self_issued_jwt_payload(), json_util_start_array(), json_util_start_object(), and mcl_json_util_initialize().
void json_util_initialize_json_library | ( | void | ) |
This function initializes json library.
Supplying malloc, realloc and free functions to cJSON is performed in this function.
Definition at line 30 of file json_util.c.
References cjson_hooks, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, mcl_memory_free(), and mcl_memory_malloc().
Referenced by core_processor_initialize(), and mcl_json_util_library_initialize().
mcl_error_t json_util_parse | ( | const char * | json_string, |
mcl_size_t | size, | ||
mcl_json_t ** | root | ||
) |
This function parses the given string to the given json object.
[in] | json_string | String in json format. |
[in] | size | Size of the buffer. If json_string is null terminated, size must be zero. Otherwise size value must be size of json_string . |
[out] | root | json_string is going to be parsed to this root object. |
Definition at line 844 of file json_util.c.
References MCL_FAIL, MCL_NULL, MCL_OK, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by _process_registration_response_rsa_3072(), _process_registration_response_shared_secret(), core_processor_get_access_token(), and mcl_json_util_parse().
mcl_error_t json_util_start_array | ( | mcl_json_t * | root, |
const char * | array_name, | ||
mcl_json_t ** | json_array | ||
) |
This function creates an array in root
.
[in] | root | Root json object. |
[in] | array_name | Name of the array which is going to be created in root . |
[out] | json_array | Json array which is going to be created in root . |
array_name
is already used in root
as object name. Definition at line 107 of file json_util.c.
References json_util_get_object_item(), json_util_initialize(), MCL_JSON_ARRAY, MCL_JSON_NAME_DUPLICATION, MCL_JSON_NON_EXISTING_CHILD, MCL_NULL, MCL_OK, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by _add_jwks(), _add_schema_to_jwt(), and mcl_json_util_start_array().
mcl_error_t json_util_start_object | ( | mcl_json_t * | root, |
const char * | object_name, | ||
mcl_json_t ** | json_object | ||
) |
This function creates an object in root
.
[in] | root | Root json object. |
[in] | object_name | Name of the object which is going to be created in root . |
[out] | json_object | Json object which is going to be created in root . |
object_name
is already used in root
as object name. Definition at line 226 of file json_util.c.
References json_util_get_object_item(), json_util_initialize(), MCL_JSON_NAME_DUPLICATION, MCL_JSON_NON_EXISTING_CHILD, MCL_JSON_OBJECT, MCL_NULL, MCL_OK, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by _add_jwks(), and mcl_json_util_start_object().
mcl_error_t json_util_to_string | ( | mcl_json_t * | root, |
char ** | json_string | ||
) |
This function gives the string of root
in json format.
[in] | root | Root json object. |
[out] | json_string | The string of root in json format. |
Definition at line 809 of file json_util.c.
References MCL_ERROR, MCL_FAIL, MCL_NULL, MCL_OK, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by _compose_rsa_key_rotation_json(), _compose_rsa_onboarding_json(), and mcl_json_util_to_string().
mcl_error_t mcl_json_util_add_bool | ( | mcl_json_t * | root, |
const char * | object_name, | ||
const mcl_bool_t | bool_value | ||
) |
This function adds bool_value
to root
which can be object or array.
[in] | root | Root json. It can be object or array. |
[in] | object_name | Name of the bool value which is going to be added to root . |
[in] | bool_value | Bool value to be added to root . |
root
is NULL. object_name
is already used in root
as object name. root
type is array and object_name
is not null, or root
type is object and object_name
is null. Definition at line 376 of file json_util.c.
References json_util_add_bool(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MCL_FUNCTION_LEAVE_LABEL.
mcl_error_t mcl_json_util_add_double | ( | mcl_json_t * | root, |
const char * | object_name, | ||
const double | number | ||
) |
This function adds double number to root
which can be object or array.
[in] | root | Root json. It can be object or array. |
[in] | object_name | Name of the name/value pair which is going to be added to root . |
[in] | number | Value of the name/value pair which is going to be added to root . |
root
is NULL. object_name
is already used in root
as object name. root
type is array and object_name
is not null, or root
type is object and object_name
is null. Definition at line 348 of file json_util.c.
References json_util_add_double(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MCL_FUNCTION_LEAVE_LABEL.
mcl_error_t mcl_json_util_add_item_to_array | ( | mcl_json_t * | root, |
mcl_json_t * | object | ||
) |
This function adds object
to root
array.
[in] | root | Root json array. |
[in] | object | object which is going to be added to root array. |
root
, object_name
or object
is NULL. Definition at line 537 of file json_util.c.
References json_util_add_item_to_array(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, and MCL_OK.
mcl_error_t mcl_json_util_add_null | ( | mcl_json_t * | root, |
const char * | object_name | ||
) |
This function adds null to root
which can be object or array.
[in] | root | Root json. It can be object or array. |
[in] | object_name | Name of the null value which is going to be added to root . |
root
is NULL. object_name
is already used in root
as object name. root
type is array and object_name
is not null, or root
type is object and object_name
is null. Definition at line 439 of file json_util.c.
References json_util_add_null(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MCL_FUNCTION_LEAVE_LABEL.
mcl_error_t mcl_json_util_add_object | ( | mcl_json_t * | root, |
const char * | object_name, | ||
mcl_json_t * | object | ||
) |
This function adds object
to root
.
[in] | root | Root json object. |
[in] | object_name | Name of object which is going to be going to be added to root . |
[in] | object | object which is going to be added to root . |
root
, object_name
or object
is NULL. object_name
is already used in root
as object name. Definition at line 494 of file json_util.c.
References json_util_add_object(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MCL_FUNCTION_LEAVE_LABEL.
mcl_error_t mcl_json_util_add_string | ( | mcl_json_t * | root, |
const char * | object_name, | ||
const char * | object_value | ||
) |
This function adds string to root
which can be object or array.
root
is array, object_name
must be null.[in] | root | Root json. It can be object or array. |
[in] | object_name | Name of the name/value pair which is going to be added to root . |
[in] | object_value | Value of the name/value pair which is going to be added to root . |
root
or object_value
is NULL. object_name
is already used in root
as object name. root
type is array and object_name
is not null, or root
type is object and object_name
is null. Definition at line 256 of file json_util.c.
References json_util_add_string(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MCL_FUNCTION_LEAVE_LABEL.
mcl_error_t mcl_json_util_add_uint | ( | mcl_json_t * | root, |
const char * | object_name, | ||
const mcl_size_t | number | ||
) |
This function adds integer number to root
which can be object or array.
root
is array, object_name
must be null.[in] | root | Root json. It can be object or array. |
[in] | object_name | Name of the name/value pair which is going to be added to root . |
[in] | number | Value of the name/value pair which is going to be added to root . |
root
is NULL. object_name
is already used in root
as object name. root
type is array and object_name
is not null, or root
type is object and object_name
is null. Definition at line 320 of file json_util.c.
References json_util_add_uint(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MCL_FUNCTION_LEAVE_LABEL.
void mcl_json_util_destroy | ( | mcl_json_t ** | root | ) |
This function destroys root
.
root
is destroyed, all child json objects in root
are also destroyed.[out] | root | Root json object. |
Definition at line 904 of file json_util.c.
References json_util_destroy(), MCL_DEBUG_ENTRY, and MCL_DEBUG_LEAVE.
mcl_error_t mcl_json_util_duplicate | ( | const mcl_json_t * | source_json, |
mcl_json_t ** | duplicated_json | ||
) |
This function duplicates source_json
as duplicated_json
.
[in] | source_json | Json object to be duplicated. |
[out] | duplicated_json | Duplicated json from source_json . |
source_json
or duplicated_json
is NULL. Definition at line 869 of file json_util.c.
References json_util_duplicate(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, and MCL_NULL.
mcl_error_t mcl_json_util_get_array_item | ( | mcl_json_t * | array, |
int | index, | ||
mcl_json_t ** | item | ||
) |
This function gets the item at given index from array
.
[in] | array | Array json object. |
[in] | index | Index of the item to get from array . |
[out] | item | Item requested. |
array
or item
is NULL. index
is out of range. array
is not a json array. Definition at line 136 of file json_util.c.
References json_util_get_array_item(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MCL_FUNCTION_LEAVE_LABEL.
mcl_error_t mcl_json_util_get_array_size | ( | mcl_json_t * | array, |
mcl_size_t * | size | ||
) |
This function returns the size of array
.
[in] | array | Array json object. |
[out] | size | Size of array . |
array
or size
is NULL. array
is not a json array. Definition at line 176 of file json_util.c.
References json_util_get_array_size(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, and MCL_OK.
mcl_error_t mcl_json_util_get_bool_value | ( | mcl_json_t * | json, |
mcl_bool_t * | bool_value | ||
) |
This function gets the boolean value of a given json object.
[in] | json | Json object to get the value. |
[out] | bool_value | Boolean value of json . |
json
or bool_value
is NULL. Definition at line 699 of file json_util.c.
References json_util_get_bool_value(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, and MCL_OK.
mcl_error_t mcl_json_util_get_double_value | ( | mcl_json_t * | json, |
double * | double_value | ||
) |
This function gets the double value of a given json object.
[in] | json | Json object to get the value. |
[out] | double_value | Value of json . |
json
or double_value
is NULL. Definition at line 666 of file json_util.c.
References json_util_get_double_value(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, and MCL_OK.
mcl_error_t mcl_json_util_get_number_value | ( | mcl_json_t * | json, |
mcl_int32_t * | number_value | ||
) |
This function gets the integer value of a given json object. Keep in mind that if the actual value of the json object is of type double, the function will truncate double value to integer and return MCL_OK.
[in] | json | Json object to get the value. |
[out] | number_value | Value of json . |
json
or number_value
is NULL. Definition at line 633 of file json_util.c.
References json_util_get_number_value(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, and MCL_OK.
mcl_error_t mcl_json_util_get_object_item | ( | mcl_json_t * | json_parent, |
const char * | child_name, | ||
mcl_json_t ** | json_child | ||
) |
This function gives the value of json_child
object, when the child_name
in json_parent
object is given.
[in] | json_parent | Root json object of json_child . |
[in] | child_name | Name of the json_child object. |
[out] | json_child | The json object which is going to be received. |
json_parent
, child_name
or json_child
is NULL. json_child
doesn't exist in json_parent
. Definition at line 563 of file json_util.c.
References json_util_get_object_item(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MCL_FUNCTION_LEAVE_LABEL.
mcl_error_t mcl_json_util_get_string | ( | mcl_json_t * | json, |
char ** | string_value | ||
) |
This function gets the string value of a given json object.
[in] | json | Json object to get the value. |
[out] | string_value | String value of json . New memory space will be allocated for this parameter. Ownership passed to caller. Caller must free the space. |
json
or string_value
is NULL. Definition at line 737 of file json_util.c.
References json_util_get_string(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MCL_FUNCTION_LEAVE_LABEL.
mcl_error_t mcl_json_util_has_child | ( | mcl_json_t * | root, |
mcl_bool_t * | result | ||
) |
This function checks whether root object has child object or not.
[in] | root | Json object which is going to be checked whether it has child or not. |
[out] | result | This bool value is going to be made true, if @ root has child. Otherwise it is false. |
root
or result
is NULL. Definition at line 600 of file json_util.c.
References json_util_has_child(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, and MCL_OK.
mcl_error_t mcl_json_util_initialize | ( | E_MCL_JSON_TYPE | json_type, |
mcl_json_t ** | root | ||
) |
This function initializes the given root
json.
[in] | json_type | Type of the json. |
[out] | root | Root json. |
root
is NULL. Definition at line 41 of file json_util.c.
References json_util_initialize(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MCL_FUNCTION_LEAVE_LABEL.
void mcl_json_util_library_initialize | ( | void | ) |
This function initializes json library.
Definition at line 21 of file json_util.c.
References json_util_initialize_json_library(), MCL_DEBUG_ENTRY, and MCL_DEBUG_LEAVE.
mcl_error_t mcl_json_util_parse | ( | const char * | json_string, |
mcl_size_t | buffer_size, | ||
mcl_json_t ** | root | ||
) |
This function parses the given string to the given json object.
[in] | json_string | String in json format. |
[in] | buffer_size | Size of the buffer.If json_string is null terminated, size must be zero. Otherwise size value must be size of json_string . |
[out] | root | json_string is going to be parsed to this root object. |
json_string
or root
is NULL. buffer
size. Definition at line 827 of file json_util.c.
References json_util_parse(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MCL_FUNCTION_LEAVE_LABEL.
mcl_error_t mcl_json_util_start_array | ( | mcl_json_t * | root, |
const char * | array_name, | ||
mcl_json_t ** | json_array | ||
) |
This function creates an array in root
.
[in] | root | Root json object. |
[in] | array_name | Name of the array which is going to be created in root . |
[out] | json_array | Json array which is going to be created in root . |
root
, array_name
or json_array
is NULL. array_name
is already used in root
as object name. Definition at line 89 of file json_util.c.
References json_util_start_array(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MCL_FUNCTION_LEAVE_LABEL.
mcl_error_t mcl_json_util_start_object | ( | mcl_json_t * | root, |
const char * | object_name, | ||
mcl_json_t ** | json_object | ||
) |
This function creates an object in root
.
[in] | root | Root json object. |
[in] | object_name | Name of the object which is going to be created in root . |
[out] | json_object | Json object which is going to be created in root . |
root
, object_name
or json_object
is NULL. object_name
is already used in root
as object name. Definition at line 208 of file json_util.c.
References json_util_start_object(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MCL_FUNCTION_LEAVE_LABEL.
mcl_error_t mcl_json_util_to_string | ( | mcl_json_t * | root, |
char ** | json_string | ||
) |
This function gives the string of root
in json format.
[in] | root | Root json object. |
[out] | json_string | The string of root in json format. New memory space will be allocated for this parameter. Ownership passed to caller. Caller must free the space. |
root
or json_string
is NULL. Definition at line 792 of file json_util.c.
References json_util_to_string(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MCL_FUNCTION_LEAVE_LABEL.
Referenced by jwt_get_token().
|
static |
Definition at line 16 of file json_util.c.
Referenced by json_util_initialize_json_library().