summaryrefslogtreecommitdiffhomepage
path: root/lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index f878d5c..af94e9a 100644
--- a/lib.c
+++ b/lib.c
@@ -368,8 +368,20 @@ static struct json_object *
ut_length(struct ut_state *s, uint32_t off, struct json_object *args)
{
struct json_object *arg = json_object_array_get_idx(args, 0);
+ size_t len;
switch (json_object_get_type(arg)) {
+ case json_type_object:
+ len = 0;
+
+ json_object_object_foreach(arg, k, v) {
+ (void)k;
+ (void)v;
+ len++;
+ }
+
+ return xjs_new_int64(len);
+
case json_type_array:
return xjs_new_int64(json_object_array_length(arg));