]> git.ipfire.org Git - thirdparty/json-c.git/commit
json_object: introduce json_object_array_insert_idx() API function
authorAlexandru Ardelean <ardeleanalex@gmail.com>
Fri, 16 Apr 2021 13:12:22 +0000 (16:12 +0300)
committerEric Hawicz <erh+git@nimenees.com>
Tue, 1 Aug 2023 02:17:30 +0000 (22:17 -0400)
commita86d7a8f5aa5d47a315931fe11e9316a2be5045f
tree80124fe3f4e044e2a6d846665a89987f1242b475
parent5568916eb14e7e56daee08123d2f2ccbe5114583
json_object: introduce json_object_array_insert_idx() API function

The behavior of the json_object_array_put_idx() is that, if a user wants to
insert an element inside a JSON array, the element will be replaced.

For some cases, a user would want to insert an element into the JSON array
and shift the elements to the right.

For indexes that are outside the length of the current array this behaves
like json_object_array_put_idx().
If a user wants to enforce that the JSON array is not expanded, then the
json_object_array_length() function can be used to guard against that.

The main driver for this change is JSON patch, where the 'add' operation in
an array means inserting a value at a certain index and shifting everything
by one.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
arraylist.c
arraylist.h
json-c.sym
json_object.c
json_object.h