cmd_error(c, "");
}
-static const char *get_string(struct json_node *n, const char *key)
+const char *get_string(struct json_node *n, const char *key)
{
struct json_node *s = json_object_get(n, key);
if (s && s->type == JSON_STRING)
return NULL;
}
+bool get_uint(struct json_node *n, const char *key, uint *dest)
+{
+ struct json_node *s = json_object_get(n, key);
+ if (s && s->type == JSON_NUMBER)
+ {
+ uint u = (uint) s->number;
+ if ((double) u == s->number)
+ {
+ *dest = u;
+ return 1;
+ }
+ }
+ *dest = 0;
+ return 0;
+}
+
+struct json_node **get_array(struct json_node *n, const char *key)
+{
+ struct json_node *s = json_object_get(n, key);
+ if (s && s->type == JSON_ARRAY)
+ return s->elements;
+ else
+ return NULL;
+}
+
+struct json_node *get_object(struct json_node *n, const char *key)
+{
+ struct json_node *s = json_object_get(n, key);
+ if (s && s->type == JSON_OBJECT)
+ return s;
+ else
+ return NULL;
+}
+
static void cmd_nop(struct client *c)
{
cmd_ok(c);