summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Hazel <ghazel@gmail.com>2013-01-11 01:36:55 -0800
committerGreg Hazel <ghazel@gmail.com>2013-01-11 01:36:55 -0800
commitcca74c6de6e0d7ea397f50c8f16bbdbff2aeae78 (patch)
tree1302bee7769194d0a0f182deceef0288ad79df09
parent3ae296f6946100e533a4358629aa34e74501a039 (diff)
downloadjson-c-cca74c6de6e0d7ea397f50c8f16bbdbff2aeae78.tar.gz
add json_object_object_length
-rw-r--r--json_object.c5
-rw-r--r--json_object.h2
-rw-r--r--linkhash.c4
-rw-r--r--linkhash.h1
4 files changed, 12 insertions, 0 deletions
diff --git a/json_object.c b/json_object.c
index 6060554..9dc6637 100644
--- a/json_object.c
+++ b/json_object.c
@@ -390,6 +390,11 @@ void json_object_object_add(struct json_object* jso, const char *key,
existing_entry->v = val;
}
+int json_object_object_length(struct json_object *jso)
+{
+ return lh_table_length(jso->o.c_object);
+}
+
struct json_object* json_object_object_get(struct json_object* jso, const char *key)
{
struct json_object *result = NULL;
diff --git a/json_object.h b/json_object.h
index 0ff6584..336ce96 100644
--- a/json_object.h
+++ b/json_object.h
@@ -215,6 +215,8 @@ extern struct json_object* json_object_new_object(void);
*/
extern struct lh_table* json_object_get_object(struct json_object *obj);
+extern int json_object_object_length(struct json_object* obj);
+
/** Add an object field to a json_object of type json_type_object
*
* The reference count will *not* be incremented. This is to make adding
diff --git a/linkhash.c b/linkhash.c
index ddedc12..2661823 100644
--- a/linkhash.c
+++ b/linkhash.c
@@ -227,3 +227,7 @@ int lh_table_delete(struct lh_table *t, const void *k)
return lh_table_delete_entry(t, e);
}
+int lh_table_length(struct lh_table *t)
+{
+ return t->count;
+}
diff --git a/linkhash.h b/linkhash.h
index bbb5488..378de0b 100644
--- a/linkhash.h
+++ b/linkhash.h
@@ -280,6 +280,7 @@ extern int lh_table_delete_entry(struct lh_table *t, struct lh_entry *e);
*/
extern int lh_table_delete(struct lh_table *t, const void *k);
+extern int lh_table_length(struct lh_table *t);
void lh_abort(const char *msg, ...);
void lh_table_resize(struct lh_table *t, int new_size);