#include "tlcllists.h"
#include "tlcdico.h"
Go to the source code of this file.
|
any_t * | parse_json_file (char const path[]) |
| parse a json file to any_t
|
|
any_t * | parse_json_str (char const *str) |
| parse a char * to any_t
|
|
int | prety_print (any_t *any, int fd) |
| print any_t to the file descriptor
|
|
any_t * | get_from_any (any_t *any, char const *format,...) |
| get unlimited nested data
|
|
any_t * | dico_t_get_any (dico_t *dico, char const *key) |
| get any_t from a dico_t (cast void * of dico_t value)
|
|
enum json_status_err_e | write_json (any_t *any, char const *path) |
| write any_t to a json file
|
|
void | destroy_any (void *data) |
| destroy any
|
|
char ** | get_any_string_array (any_t *array) |
| parse any_t to a char **
|
|
int * | get_any_int_array (any_t *array) |
| parse any_t to a int *
|
|
float * | get_any_float_array (any_t *array) |
| parse any_t to a float *
|
|
any_t * | create_empty_json (void) |
| create an empty any (useful to build a json)
|
|
any_t * | creator_add_any (any_t *root, const char *key, any_t *any) |
| add an any_t to the any dico
|
|
any_t * | creator_add_int (any_t *root, const char *key, int number) |
| add a number to the any dico
|
|
any_t * | creator_add_float (any_t *root, const char *key, float number) |
| add a number to the any dico
|
|
any_t * | creator_add_string (any_t *root, const char *key, const char *string) |
| add a string to the any dico
|
|
◆ any_type_t
◆ any_type_e
Enumerator |
---|
STR | |
INT | |
FLOAT | |
ARRAY | |
DICT | |
Definition at line 21 of file tlcjson.h.
◆ json_status_err_e
Enumerator |
---|
JS_OK | |
JS_ERR_PATH | |
JS_ERR_MALLOC | |
JS_ERR_INPUT | |
Definition at line 14 of file tlcjson.h.
◆ create_empty_json()
any_t * create_empty_json |
( |
void |
| ) |
|
create an empty any (useful to build a json)
- Returns
- NULL if error; any_t * otherwise
◆ creator_add_any()
any_t * creator_add_any |
( |
any_t * |
root, |
|
|
const char * |
key, |
|
|
any_t * |
any |
|
) |
| |
add an any_t to the any dico
- Parameters
-
root | the root of the dico |
key | the key |
any | the any (take ownership of this parameter) |
- Returns
- the root
◆ creator_add_float()
any_t * creator_add_float |
( |
any_t * |
root, |
|
|
const char * |
key, |
|
|
float |
number |
|
) |
| |
add a number to the any dico
- Parameters
-
root | the root of the dico |
key | the key |
number | the number |
- Returns
- the root
◆ creator_add_int()
any_t * creator_add_int |
( |
any_t * |
root, |
|
|
const char * |
key, |
|
|
int |
number |
|
) |
| |
add a number to the any dico
- Parameters
-
root | the root of the dico |
key | the key |
number | the number |
- Returns
- the root
◆ creator_add_string()
any_t * creator_add_string |
( |
any_t * |
root, |
|
|
const char * |
key, |
|
|
const char * |
string |
|
) |
| |
add a string to the any dico
- Parameters
-
root | the root of the dico |
key | the key |
string | the string |
- Returns
- the root
◆ destroy_any()
void destroy_any |
( |
void * |
data | ) |
|
◆ dico_t_get_any()
any_t * dico_t_get_any |
( |
dico_t * |
dico, |
|
|
char const * |
key |
|
) |
| |
get any_t from a dico_t (cast void * of dico_t value)
- Parameters
-
dico | dico in which the key are |
key | key to represent the value |
- Returns
- { NULL : dico or key is NULL, NULL : the key don't exists any_t *: the value asked }
◆ get_any_float_array()
float * get_any_float_array |
( |
any_t * |
array | ) |
|
parse any_t to a float *
- Parameters
-
array | any_t in which the array float is |
- Returns
- { NULL : array is NULL, NULL : array contains other than float, float *: the values asked (array of float) }
◆ get_any_int_array()
int * get_any_int_array |
( |
any_t * |
array | ) |
|
parse any_t to a int *
- Parameters
-
array | any_t in which the array int is |
- Returns
- { NULL : array is NULL, NULL : array contains other than int int *: the values asked (array of int) }
◆ get_any_string_array()
char ** get_any_string_array |
( |
any_t * |
array | ) |
|
parse any_t to a char **
- Parameters
-
array | any_t in which the array of char * is |
- Returns
- { NULL : array is NULL, NULL : array contains other than char *, char **: the values asked (array of char *) }
◆ get_from_any()
any_t * get_from_any |
( |
any_t * |
any, |
|
|
char const * |
format, |
|
|
|
... |
|
) |
| |
get unlimited nested data
to get value of a dico : "d", "key" to get specific index array : "a", 2 you can mix the two (any, "da", "key", 2)
- Parameters
-
any | any in wich the values are |
format | format to use |
... | unlimited arguments |
- Returns
- { NULL : any or format is NULL, NULL : the value don't exists, any_t *: the value asked }
◆ parse_json_file()
any_t * parse_json_file |
( |
char const |
path[] | ) |
|
parse a json file to any_t
- Parameters
-
path | path to the json file |
- Returns
- { NULL : path is NULL, NULL : path is bad, NULL : malloc failed, any_t *: the file has been parsed }
◆ parse_json_str()
any_t * parse_json_str |
( |
char const * |
str | ) |
|
parse a char * to any_t
- Parameters
-
- Returns
- { NULL : str is NULL, NULL : malloc failed, any_t *: the char * has been parsed }
◆ prety_print()
int prety_print |
( |
any_t * |
any, |
|
|
int |
fd |
|
) |
| |
print any_t to the file descriptor
- Parameters
-
any | the any_t to print |
fd | filedescriptor to use |
- Returns
- { int : number of char writed }
◆ write_json()
write any_t to a json file
- Parameters
-
any | any to write |
path | path to a file that will be override |
- Returns
- status under the form of the enum