diff options
Diffstat (limited to 'src/json-gram.y')
-rw-r--r-- | src/json-gram.y | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/json-gram.y b/src/json-gram.y index ecfb561..ab65362 100644 --- a/src/json-gram.y +++ b/src/json-gram.y @@ -485,7 +485,7 @@ json_array_insert(struct json_value *j, size_t idx, struct json_value *v) int json_array_append(struct json_value *j, struct json_value *v) { - if (j->type != json_arr) { + if (j->type != json_arr) { errno = EINVAL; return -1; } @@ -497,6 +497,22 @@ json_array_append(struct json_value *j, struct json_value *v) } int +json_array_set(struct json_value *j, size_t idx, struct json_value *v) +{ + if (j->type != json_arr) { + errno = EINVAL; + return -1; + } + if (idx >= json_array_size(j)) { + errno = ENOENT; + return -1; + } + json_array_flatten(j); + j->v.a->ov[idx] = v; + return 0; +} + +int json_array_get(struct json_value *j, size_t idx, struct json_value **retval) { if (j->type != json_arr) { |