5b8ebecea5c712d9a946a3fbe949e57eaa9f4e9f
[src/app-framework-main.git] / src / utils-json.h
1 /*
2  Copyright 2015 IoT.bzh
3
4  author: José Bollo <jose.bollo@iot.bzh>
5
6  Licensed under the Apache License, Version 2.0 (the "License");
7  you may not use this file except in compliance with the License.
8  You may obtain a copy of the License at
9
10      http://www.apache.org/licenses/LICENSE-2.0
11
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  See the License for the specific language governing permissions and
16  limitations under the License.
17 */
18
19 #define j_is_string(o)          (json_object_get_type(o) == json_type_string)
20 #define j_is_boolean(o)         (json_object_get_type(o) == json_type_boolean)
21 #define j_is_integer(o)         (json_object_get_type(o) == json_type_int)
22
23 extern int j_read_string(struct json_object *obj, const char **value);
24 extern int j_read_boolean(struct json_object *obj, int *value);
25 extern int j_read_integer(struct json_object *obj, int *value);
26
27 extern const char *j_string(struct json_object *obj, const char *defval);
28 extern int j_boolean(struct json_object *obj, int defval);
29 extern int j_integer(struct json_object *obj, int defval);
30
31 extern int j_read_object_at(struct json_object *obj, const char *key, struct json_object **value);
32 extern int j_read_string_at(struct json_object *obj, const char *key, const char **value);
33 extern int j_read_boolean_at(struct json_object *obj, const char *key, int *value);
34 extern int j_read_integer_at(struct json_object *obj, const char *key, int *value);
35
36 extern const char *j_string_at(struct json_object *obj, const char *key, const char *defval);
37 extern int j_boolean_at(struct json_object *obj, const char *key, int defval);
38 extern int j_integer_at(struct json_object *obj, const char *key, int defval);
39
40 extern int j_add(struct json_object *obj, const char *key, struct json_object *val);
41 extern int j_add_string(struct json_object *obj, const char *key, const char *val);
42 extern int j_add_boolean(struct json_object *obj, const char *key, int val);
43 extern int j_add_integer(struct json_object *obj, const char *key, int val);
44