diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-06-28 15:26:54 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-06-28 15:26:54 +0300 |
commit | ee381fcca128d8eccf498ef19f68639504b5f4a6 (patch) | |
tree | 59f9743d9ee9a51be8885f21ae38ffc0e7512d41 /src | |
parent | d8f371dde9dd660c6067a173e70289c33e2a26c0 (diff) | |
download | unit-ee381fcca128d8eccf498ef19f68639504b5f4a6.tar.gz unit-ee381fcca128d8eccf498ef19f68639504b5f4a6.tar.bz2 |
JSON property iterator nxt_conf_json_object_next_member().
Diffstat (limited to '')
-rw-r--r-- | src/nxt_conf.h | 2 | ||||
-rw-r--r-- | src/nxt_conf_json.c | 28 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/nxt_conf.h b/src/nxt_conf.h index 4fe88404..fdb324d7 100644 --- a/src/nxt_conf.h +++ b/src/nxt_conf.h @@ -43,6 +43,8 @@ nxt_conf_json_value_t *nxt_conf_json_get_value(nxt_conf_json_value_t *value, nxt_str_t *path); nxt_conf_json_value_t *nxt_conf_json_object_get_member( nxt_conf_json_value_t *value, nxt_str_t *name, uint32_t *index); +nxt_conf_json_value_t *nxt_conf_json_object_next_member( + nxt_conf_json_value_t *value, nxt_str_t *name, uint32_t *next); nxt_int_t nxt_conf_json_object_map(nxt_conf_json_value_t *value, nxt_conf_json_object_map_t *map, void *data); diff --git a/src/nxt_conf_json.c b/src/nxt_conf_json.c index 0f4b3271..45682245 100644 --- a/src/nxt_conf_json.c +++ b/src/nxt_conf_json.c @@ -370,6 +370,34 @@ nxt_conf_json_object_map(nxt_conf_json_value_t *value, } +nxt_conf_json_value_t * +nxt_conf_json_object_next_member(nxt_conf_json_value_t *value, nxt_str_t *name, + uint32_t *next) +{ + uint32_t n; + nxt_conf_json_object_t *object; + nxt_conf_json_obj_member_t *member; + + if (value->type != NXT_CONF_JSON_OBJECT) { + return NULL; + } + + n = *next; + object = value->u.object; + + if (n >= object->count) { + return NULL; + } + + member = &object->members[n]; + *next = n + 1; + + nxt_conf_json_value_get_string(&member->name, name); + + return &member->value; +} + + nxt_int_t nxt_conf_json_op_compile(nxt_mp_t *mp, nxt_conf_json_op_t **ops, nxt_conf_json_value_t *root, nxt_str_t *path, |