aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils-json.h
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-02-11 16:14:16 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2016-02-11 16:14:16 +0100
commit6b3c3b1916b0af0494041c12a3c86819e441105e (patch)
tree4eac9853f62456d69211321ef7cb8c3819c20cdd /src/utils-json.h
parentbf650bc39188c86cec8a11097f2c341e3f1b54b1 (diff)
utils-json: refactoring
Change-Id: Ie8b49279e727afdbce7b9ea74c767d560c93af32 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/utils-json.h')
-rw-r--r--src/utils-json.h28
1 files changed, 20 insertions, 8 deletions
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);