Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
// Add the object
return json_object_object_add(json, name, object);
}
+
+int pakfire_json_get_int64(struct json_object* json, const char* key, int64_t* value) {
+ struct json_object* object = NULL;
+ int r;
+
+ // Fetch the object
+ r = json_object_object_get_ex(json, key, &object);
+ if (!r)
+ return -ENOMSG;
+
+ // Check if this is an integer
+ r = json_object_is_type(object, json_type_int);
+ if (!r)
+ return -ENOMSG;
+
+ // Return the value
+ *value = json_object_get_int64(object);
+
+ return 0;
+}
int pakfire_json_add_object(struct json_object* json, const char* name, struct json_object** o);
int pakfire_json_add_array(struct json_object* json, const char* name, struct json_object** array);
+int pakfire_json_get_int64(struct json_object* json, const char* key, int64_t* value);
+
#endif /* PAKFIRE_JSON_H */