Commit cc7baf7
authored
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.
1 parent 11fa7e4 commit cc7baf7
2 files changed
+18
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
599 | 599 | | |
600 | 600 | | |
601 | 601 | | |
602 | | - | |
| 602 | + | |
603 | 603 | | |
604 | 604 | | |
605 | 605 | | |
606 | 606 | | |
607 | 607 | | |
608 | | - | |
609 | | - | |
610 | | - | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
611 | 613 | | |
612 | 614 | | |
613 | 615 | | |
| |||
627 | 629 | | |
628 | 630 | | |
629 | 631 | | |
630 | | - | |
| 632 | + | |
631 | 633 | | |
632 | 634 | | |
633 | 635 | | |
| |||
776 | 778 | | |
777 | 779 | | |
778 | 780 | | |
779 | | - | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
780 | 784 | | |
781 | 785 | | |
782 | 786 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
392 | 392 | | |
393 | 393 | | |
394 | 394 | | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
395 | 403 | | |
396 | 404 | | |
397 | 405 | | |
| |||
0 commit comments