mcl_json_util.h File Reference

Json utility module interface header file. More...

Include dependency graph for mcl_json_util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void mcl_json_t
 

Enumerations

enum  E_MCL_JSON_TYPE { MCL_JSON_ARRAY, MCL_JSON_OBJECT }
 

Functions

MCL_CORE_EXPORT void mcl_json_util_library_initialize (void)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_initialize (E_MCL_JSON_TYPE json_type, mcl_json_t **root)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_start_array (mcl_json_t *root, const char *array_name, mcl_json_t **json_array)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_get_array_item (mcl_json_t *array, int index, mcl_json_t **item)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_get_array_size (mcl_json_t *array, mcl_size_t *size)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_start_object (mcl_json_t *root, const char *object_name, mcl_json_t **json_object)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_add_string (mcl_json_t *root, const char *object_name, const char *object_value)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_add_uint (mcl_json_t *root, const char *object_name, const mcl_size_t number)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_add_double (mcl_json_t *root, const char *object_name, const double number)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_add_bool (mcl_json_t *root, const char *object_name, const mcl_bool_t bool_value)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_add_null (mcl_json_t *root, const char *object_name)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_add_object (mcl_json_t *root, const char *object_name, mcl_json_t *object)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_add_item_to_array (mcl_json_t *root, mcl_json_t *object)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_get_object_item (mcl_json_t *json_parent, const char *child_name, mcl_json_t **json_child)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_has_child (mcl_json_t *root, mcl_bool_t *result)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_get_number_value (mcl_json_t *json, mcl_int32_t *number_value)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_get_double_value (mcl_json_t *json, double *double_value)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_get_bool_value (mcl_json_t *json, mcl_bool_t *bool_value)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_get_string (mcl_json_t *json, char **string_value)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_to_string (mcl_json_t *root, char **json_string)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_parse (const char *json_string, mcl_size_t buffer_size, mcl_json_t **root)
 
MCL_CORE_EXPORT mcl_error_t mcl_json_util_duplicate (const mcl_json_t *source_json, mcl_json_t **duplicated_json)
 
MCL_CORE_EXPORT void mcl_json_util_destroy (mcl_json_t **root)
 

Detailed Description

Json utility module interface header file.

This module is used for json handling like json parsing and json generating.

Definition in file mcl_json_util.h.

Typedef Documentation

typedef void mcl_json_t

Handle for json.

Definition at line 24 of file mcl_json_util.h.

Enumeration Type Documentation

Json type definitions.

Enumerator
MCL_JSON_ARRAY 

Json array.

MCL_JSON_OBJECT 

Json object.

Definition at line 29 of file mcl_json_util.h.

Function Documentation

MCL_CORE_EXPORT 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.

Parameters
[in]rootRoot json. It can be object or array.
[in]object_nameName of the bool value which is going to be added to root.
[in]bool_valueBool value to be added to root.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Parameters
[in]rootRoot json. It can be object or array.
[in]object_nameName of the name/value pair which is going to be added to root.
[in]numberValue of the name/value pair which is going to be added to root.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Parameters
[in]rootRoot json array.
[in]objectobject which is going to be added to root array.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Parameters
[in]rootRoot json. It can be object or array.
[in]object_nameName of the null value which is going to be added to root.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Parameters
[in]rootRoot json object.
[in]object_nameName of object which is going to be going to be added to root.
[in]objectobject which is going to be added to root.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Note
if root is array, object_name must be null.
Parameters
[in]rootRoot json. It can be object or array.
[in]object_nameName of the name/value pair which is going to be added to root.
[in]object_valueValue of the name/value pair which is going to be added to root.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Note
if root is array, object_name must be null.
Parameters
[in]rootRoot json. It can be object or array.
[in]object_nameName of the name/value pair which is going to be added to root.
[in]numberValue of the name/value pair which is going to be added to root.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT void mcl_json_util_destroy ( mcl_json_t **  root)

This function destroys root.

Note
If root is destroyed, all child json objects in root are also destroyed.
Parameters
[out]rootRoot json object.

Definition at line 904 of file json_util.c.

References json_util_destroy(), MCL_DEBUG_ENTRY, and MCL_DEBUG_LEAVE.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Parameters
[in]source_jsonJson object to be duplicated.
[out]duplicated_jsonDuplicated json from source_json.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Parameters
[in]arrayArray json object.
[in]indexIndex of the item to get from array.
[out]itemItem requested.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT mcl_error_t mcl_json_util_get_array_size ( mcl_json_t array,
mcl_size_t size 
)

This function returns the size of array.

Parameters
[in]arrayArray json object.
[out]sizeSize of array.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Parameters
[in]jsonJson object to get the value.
[out]bool_valueBoolean value of json.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Parameters
[in]jsonJson object to get the value.
[out]double_valueValue of json.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Parameters
[in]jsonJson object to get the value.
[out]number_valueValue of json.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Parameters
[in]json_parentRoot json object of json_child.
[in]child_nameName of the json_child object.
[out]json_childThe json object which is going to be received.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Parameters
[in]jsonJson object to get the value.
[out]string_valueString value of json. New memory space will be allocated for this parameter. Ownership passed to caller. Caller must free the space.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Parameters
[in]rootJson object which is going to be checked whether it has child or not.
[out]resultThis bool value is going to be made true, if @ root has child. Otherwise it is false.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT mcl_error_t mcl_json_util_initialize ( E_MCL_JSON_TYPE  json_type,
mcl_json_t **  root 
)

This function initializes the given root json.

Parameters
[in]json_typeType of the json.
[out]rootRoot json.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Parameters
[in]json_stringString in json format.
[in]buffer_sizeSize of the buffer.If json_string is null terminated, size must be zero. Otherwise size value must be size of json_string.
[out]rootjson_string is going to be parsed to this root object.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Parameters
[in]rootRoot json object.
[in]array_nameName of the array which is going to be created in root.
[out]json_arrayJson array which is going to be created in root.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Parameters
[in]rootRoot json object.
[in]object_nameName of the object which is going to be created in root.
[out]json_objectJson object which is going to be created in root.
Returns

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.

Here is the call graph for this function:

MCL_CORE_EXPORT 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.

Parameters
[in]rootRoot json object.
[out]json_stringThe string of root in json format. New memory space will be allocated for this parameter. Ownership passed to caller. Caller must free the space.
Returns

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().

Here is the call graph for this function:

Here is the caller graph for this function: