X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fcurl_json.c;h=ff07e76b54a631b693d345d4d0874b90122daa4b;hb=9c3ed6462c15fd1cb664cd0ec2a5efb289aa1af6;hp=9e0f6723c35c363198a3f1df165a6c5e8dcdb444;hpb=21077b074c468a41dbd60baad691ebc7f2991d43;p=collectd.git diff --git a/src/curl_json.c b/src/curl_json.c index 9e0f6723..ff07e76b 100644 --- a/src/curl_json.c +++ b/src/curl_json.c @@ -232,9 +232,14 @@ static int cj_cb_number (void *ctx, if (key != NULL) NOTICE ("curl_json plugin: Found \"%s\", but the configuration expects" " a map.", buffer); - cj_cb_inc_array_index (ctx, /* update_key = */ 0); - return (CJ_CB_CONTINUE); - } else { + cj_cb_inc_array_index (ctx, /* update_key = */ 1); + key = db->state[db->depth].key; + if (key == NULL) { + return (CJ_CB_CONTINUE); + } + } + else + { cj_cb_inc_array_index (ctx, /* update_key = */ 1); } @@ -274,10 +279,21 @@ static int cj_cb_map_key (void *ctx, memcpy (name, in_name, name_len); name[name_len] = 0; - if (c_avl_get (tree, name, (void *) &value) == 0) - db->state[db->depth].key = value; + if (c_avl_get (tree, name, (void *) &value) == 0) { + if (CJ_IS_KEY((cj_key_t*)value)) { + db->state[db->depth].key = value; + } + else { + db->state[db->depth].tree = (c_avl_tree_t*) value; + } + } else if (c_avl_get (tree, CJ_ANY, (void *) &value) == 0) - db->state[db->depth].key = value; + if (CJ_IS_KEY((cj_key_t*)value)) { + db->state[db->depth].key = value; + } + else { + db->state[db->depth].tree = (c_avl_tree_t*) value; + } else db->state[db->depth].key = NULL; } @@ -533,7 +549,6 @@ static int cj_config_add_key (cj_t *db, /* {{{ */ db->tree = cj_avl_create(); tree = db->tree; - name = key->path; ptr = key->path; if (*ptr == '/') ++ptr;