X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Futils-json.h;h=c155a61e27e076959d560f944a7544f3ad96e7b0;hb=2a319cf90daa6e3b01e8139923f7073e1c9bcf28;hp=4b86fa9f264de9aeb91245c75bd19051427cf8bf;hpb=e906126c4e46ad9f3471aee208f096f55289ca03;p=src%2Fapp-framework-main.git diff --git a/src/utils-json.h b/src/utils-json.h index 4b86fa9..c155a61 100644 --- a/src/utils-json.h +++ b/src/utils-json.h @@ -1,5 +1,5 @@ /* - Copyright 2015 IoT.bzh + Copyright (C) 2015-2019 IoT.bzh author: José Bollo @@ -42,6 +42,7 @@ extern int j_integer(struct json_object *obj, int defval); * Read the value of the entry of key in object if exist and of the good type and return true. * Returns false if the key does not exist or if the type is not correct. */ +extern int j_has(struct json_object *obj, const char *key); extern int j_read_object_at(struct json_object *obj, const char *key, struct json_object **value); extern int j_read_string_at(struct json_object *obj, const char *key, const char **value); extern int j_read_boolean_at(struct json_object *obj, const char *key, int *value); @@ -56,9 +57,38 @@ extern int j_integer_at(struct json_object *obj, const char *key, int defval); /* * Adds a keyed value (of type) and returns true if done or false in case of error + * when key==NULL object is an array and values are appended */ extern int j_add(struct json_object *obj, const char *key, struct json_object *val); extern int j_add_string(struct json_object *obj, const char *key, const char *val); extern int j_add_boolean(struct json_object *obj, const char *key, int val); extern int j_add_integer(struct json_object *obj, const char *key, int val); +extern struct json_object *j_add_new_array(struct json_object *obj, const char *key); +extern struct json_object *j_add_new_object(struct json_object *obj, const char *key); + +/* + * functions below interpret the key 'mkey' as a dot separated + * path specification. + */ +extern int j_enter_m(struct json_object **obj, const char **mkey, int create); + +extern int j_has_m(struct json_object *obj, const char *mkey); + +extern int j_read_object_at_m(struct json_object *obj, const char *mkey, struct json_object **value); +extern int j_read_string_at_m(struct json_object *obj, const char *mkey, const char **value); +extern int j_read_boolean_at_m(struct json_object *obj, const char *mkey, int *value); +extern int j_read_integer_at_m(struct json_object *obj, const char *mkey, int *value); + +extern const char *j_string_at_m(struct json_object *obj, const char *mkey, const char *defval); +extern int j_boolean_at_m(struct json_object *obj, const char *mkey, int defval); +extern int j_integer_at_m(struct json_object *obj, const char *mkey, int defval); + +extern int j_add_m(struct json_object *obj, const char *mkey, struct json_object *val); +extern int j_add_string_m(struct json_object *obj, const char *mkey, const char *val); +extern int j_add_many_strings_m(struct json_object *obj, ...); +extern int j_add_boolean_m(struct json_object *obj, const char *mkey, int val); +extern int j_add_integer_m(struct json_object *obj, const char *mkey, int val); +extern struct json_object *j_add_new_array_m(struct json_object *obj, const char *mkey); +extern struct json_object *j_add_new_object_m(struct json_object *obj, const char *mkey); +