From 6b3c3b1916b0af0494041c12a3c86819e441105e Mon Sep 17 00:00:00 2001 From: José Bollo Date: Thu, 11 Feb 2016 16:14:16 +0100 Subject: utils-json: refactoring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie8b49279e727afdbce7b9ea74c767d560c93af32 Signed-off-by: José Bollo --- src/utils-json.h | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/utils-json.h') diff --git a/src/utils-json.h b/src/utils-json.h index 9778347..5b8ebec 100644 --- a/src/utils-json.h +++ b/src/utils-json.h @@ -16,14 +16,26 @@ limitations under the License. */ -int j_object(struct json_object *obj, const char *key, struct json_object **value); -int j_string(struct json_object *obj, const char *key, const char **value); -int j_boolean(struct json_object *obj, const char *key, int *value); -int j_integer(struct json_object *obj, const char *key, int *value); - -extern const char *j_get_string(struct json_object *obj, const char *key, const char *defval); -extern int j_get_boolean(struct json_object *obj, const char *key, int defval); -extern int j_get_integer(struct json_object *obj, const char *key, int defval); +#define j_is_string(o) (json_object_get_type(o) == json_type_string) +#define j_is_boolean(o) (json_object_get_type(o) == json_type_boolean) +#define j_is_integer(o) (json_object_get_type(o) == json_type_int) + +extern int j_read_string(struct json_object *obj, const char **value); +extern int j_read_boolean(struct json_object *obj, int *value); +extern int j_read_integer(struct json_object *obj, int *value); + +extern const char *j_string(struct json_object *obj, const char *defval); +extern int j_boolean(struct json_object *obj, int defval); +extern int j_integer(struct json_object *obj, int defval); + +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); +extern int j_read_integer_at(struct json_object *obj, const char *key, int *value); + +extern const char *j_string_at(struct json_object *obj, const char *key, const char *defval); +extern int j_boolean_at(struct json_object *obj, const char *key, int defval); +extern int j_integer_at(struct json_object *obj, const char *key, int defval); 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); -- cgit 1.2.3-korg