group
group__libshare__memjson
Provides the capability to generate or parse a JSON formatted context.
JSON Format Encoder
char* shjson_print
(shjson_t *json)
A JSON text-format of the specified hierarchy.
Return Value
An allocated string in JSON format.
char* shjson_Print
(shjson_t *item)
A human-readable JSON text-format of the specified hierarchy.
Return Value
An allocated string in JSON format.
char* shjson_str
(shjson_t *json, char *name, char *def_str)
Obtain an allocated string value from a JSON object.
Param
tree
The JSON object containing the string value.
name
The name of the string JSON node.
def_str
The default string value if the JSON node does not exist.
Return Value
The string value contained in the JSON node.
char* shjson_astr
(shjson_t *json, char *name, char *def_str)
Obtain an un-allocated string value from a JSON object.
Param
tree
The JSON object containing the string value.
name
The name of the string JSON node.
def_str
The default string value if the JSON node does not exist.
Return Value
The string value contained in the JSON node.
shjson_t* shjson_str_add
(shjson_t *tree, char *name, char *val)
Add a string value to a JSON object or array.
Param
tree
The JSON object containing the string value.
name
The name of the string JSON node.
val
The string value to store in the new JSON node.
Return Value
The new JSON node containing the string value.
void shjson_free
(shjson_t **tree_p)
De-allocates memory associated with a JSON hiearchy.
Param
tree_p
A reference to the JSON hierarchy.
See
shjson_init()
group__libshare__memjson_1ga6a003b3ec511a1f68258088cad1d70ea
member
double shjson_num
(shjson_t *json, char *name, double def_d)
Obtain a number value from a JSON object.
Param
tree
The JSON object containing the number value.
name
The name of the number JSON node.
def_d
The default number value if the JSON node does not exist.
Return Value
The number value contained in the JSON node.
shjson_t* shjson_num_add
(shjson_t *tree, char *name, double num)
Add a number value to a JSON object or array.
Param
tree
The JSON object or array to add the number value.
name
The name of the number JSON node or NULL if is an array.
tree
idx
The number value to store in the new JSON node.
Return Value
The new JSON node containing the number value.
shjson_t* shjson_init
(char *json_str)
Create a new JSON tree hierarchy.
Param
json_str
A JSON formatted text string or NULL.
Return Value
A new JSON object if is null or a full JSON node hierarchy otherwise.
json_str
See
shjson_print
group__libshare__memjson_1ga4c996046c84e6237ba31f7e8242556c1
member
shjson_free
group__libshare__memjson_1gae9a7788305c14ad5cfb2b08c8d1a1fb4
member
shjson_t* shjson_array_add
(shjson_t *tree, char *name)
Create a new JSON node at the end of an array.
Param
json
The JSON object containing the array.
name
The name of the array in the JSON object.
Return Value
A new JSON node attachd to the array.
int shjson_array_count
(shjson_t *json, char *name)
shjson_t* shjson_obj_add
(shjson_t *tree, char *name)
Create a new object JSON node.
Param
name
The name of the object or NULL if appending to an array.
char* shjson_array_str
(shjson_t *json, char *name, int idx)
Obtain an allocated string value from an array.
Param
json
The JSON object containing the array.
name
The name of the array in the JSON object.
idx
The index number of the JSON node in the array.
Return Value
The string value contained in the array's node index.
Note
The string pointer returned must be de-allocated.
char* shjson_array_astr
(shjson_t *json, char *name, int idx)
Obtain an un-allocated string value from an array.
Param
json
The JSON object containing the array.
name
The name of the array in the JSON object.
idx
The index number of the JSON node in the array.
Return Value
The string value contained in the array's node index.
Note
Do not free the string pointer returned.
double shjson_array_num
(shjson_t *json, char *name, int idx)
Obtain a number value from an array.
Param
json
The JSON object containing the array.
name
The name of the array in the JSON object.
idx
The index number of the JSON node in the array.
Return Value
The numeric value contained in the array's node index.
shjson_t* shjson_obj
(shjson_t *json, char *name)
Return Value
A JSON object contained inside another object.
size_t shjson_strlen
(shjson_t *json, char *name)
Return Value
The string length of a JSON object node.
shjson_t* shjson_obj_get
(shjson_t *json, char *name)