Change-Id: I6d536d730af71b18e78720839522b82aed63c0d4
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
int j_add(struct json_object *obj, const char *key, struct json_object *val)
{
- json_object_object_add(obj, key, val);
+ if (key)
+ json_object_object_add(obj, key, val);
+ else
+ json_object_array_add(obj, val);
return 1;
}
/*
* 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);