+// build an ERROR message and return it as a valid json object
+json_object *json_add_status (json_object *obj, const char *status, const char *info)
+{
+ if (obj == NULL)
+ obj = json_object_new_object();
+ json_object_object_add(obj, "status", json_object_new_string(status));
+ if (info)
+ json_object_object_add(obj, "info", json_object_new_string(info));
+ return obj;
+}
+
+// build an ERROR message and return it as a valid json object
+json_object *json_add_status_v (json_object *obj, const char *status, const char *info, va_list args)
+{
+ char *message;
+ if (info == NULL || vasprintf(&message, info, args) < 0)
+ message = NULL;
+ obj = json_add_status(obj, status, message);
+ free(message);
+ return obj;
+}
+
+
+// build an ERROR message and return it as a valid json object
+json_object *json_add_status_f (json_object *obj, const char *status, const char *info, ...)
+{
+ va_list args;
+ va_start(args, info);
+ obj = json_add_status_v(obj, status, info, args);
+ va_end(args);
+ return obj;
+}
+
+
+