aboutsummaryrefslogtreecommitdiff
path: root/src/value.c
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2011-01-24 21:45:54 +0200
committerPetri Lehtinen <petri@digip.org>2011-01-25 08:53:55 +0200
commit2770dca2c091a9c5c898ff0922d905449111ff95 (patch)
tree00d86508bae45ec3e5b80fe018bbe55313310217 /src/value.c
parent6825c2c706276312593cfe3cb770df644a539c21 (diff)
downloadjansson-2770dca2c091a9c5c898ff0922d905449111ff95.zip
jansson-2770dca2c091a9c5c898ff0922d905449111ff95.tar.gz
jansson-2770dca2c091a9c5c898ff0922d905449111ff95.tar.bz2
Add validation features to json_unpack()
* By default, json_unpack() now checks that all items of arrays and objects are unpacked. This is useful for validation. * Add format specifier '*' to suppress this check for individual arrays and objects. '*' must appear as the last format specifier before the closing ']' or '}'.
Diffstat (limited to 'src/value.c')
-rw-r--r--src/value.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/value.c b/src/value.c
index 0df4570..534624c 100644
--- a/src/value.c
+++ b/src/value.c
@@ -32,7 +32,7 @@ static JSON_INLINE void json_init(json_t *json, json_type type)
an object_key_t instance. */
#define string_to_key(string) container_of(string, object_key_t, key)
-static size_t hash_key(const void *ptr)
+size_t jsonp_hash_key(const void *ptr)
{
const char *str = ((const object_key_t *)ptr)->key;
@@ -48,7 +48,7 @@ static size_t hash_key(const void *ptr)
return hash;
}
-static int key_equal(const void *ptr1, const void *ptr2)
+int jsonp_key_equal(const void *ptr1, const void *ptr2)
{
return strcmp(((const object_key_t *)ptr1)->key,
((const object_key_t *)ptr2)->key) == 0;
@@ -66,7 +66,8 @@ json_t *json_object(void)
return NULL;
json_init(&object->json, JSON_OBJECT);
- if(hashtable_init(&object->hashtable, hash_key, key_equal,
+ if(hashtable_init(&object->hashtable,
+ jsonp_hash_key, jsonp_key_equal,
free, value_decref))
{
free(object);