]> granicus.if.org Git - json-c/commitdiff
add json_object_object_length
authorGreg Hazel <ghazel@gmail.com>
Fri, 11 Jan 2013 09:36:55 +0000 (01:36 -0800)
committerGreg Hazel <ghazel@gmail.com>
Fri, 11 Jan 2013 09:36:55 +0000 (01:36 -0800)
json_object.c
json_object.h
linkhash.c
linkhash.h

index 6060554a7c86b7835402c7b68ae3b913a4db8a5e..9dc66375e8bb551a763d2869d74da130a9bb5e6c 100644 (file)
@@ -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;
index 0ff6584554ee60905e4b8571b0c26d038bcf6476..336ce96a6fb2edca3d92f8abdfa8175341fc194b 100644 (file)
@@ -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
index ddedc1268fcbb4d02603a1999c3a94d63752d46d..2661823925aa402bd27a1833a9244bc9558ffea4 100644 (file)
@@ -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;
+}
index bbb5488604066bbecc0fc5d8964f9a554102158d..378de0b76c25e40d8d4dbd49568eff9b03bad50a 100644 (file)
@@ -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);