Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
If you try to set an unknown key, simple object within a nested array, passing in the index, the parser will override the object and does not take into account the given index [1]. With current parser version, given this json as input: ```json { "test": { "key": [ { "innerKey": "innerKeyValue", "innerKey2": "innerKeyValue2" } ] } } ``` and following path to set an unknown key: `"test", "key", "[1]", "newInnerKey"` with data `"new object"`, the output would be: ```json { "test": { "key": [ { "newInnerKey": "new object" } ] } } ``` which I think it is wrong, since it overrides what index [0] had but the above path wanted to insert the object in index [1] instead. With the changes done in this PR, given the same json input, path and data, the output would be: ```json { "test": { "key": [ { "innerKey": "innerKeyValue", "innerKey2": "innerKeyValue2" }, { "newInnerKey": "new object" } ] } } ``` the above result would be correct since we are setting a new object within the existing array in a different index [1], keeping what the array already had in previous index [0]. Added also a test to cover this scenario. All tests pass. This appears to fix #185 and includes a test for it. **Description**: What this PR does **Benchmark before change**: Benchmarks are broken.
- Loading branch information