Open maxlk opened 5 years ago
This is biting me on my project, too. This repl.it demonstrates the issue https://repl.it/repls/BouncyInfantilePrograms which returns error OPERATION_VALUE_OUT_OF_BOUNDS
var compare = require('fast-json-patch').compare;
var validate = require('fast-json-patch').validate;
const ogData = {
key: ['foo'],
};
const newData = {
key: ['foo',,, 'bar'],
};
const patch = compare(ogData, newData);
console.log(patch, validate(patch, ogData));
According to RFC 6902, when
add
operation is used to insert a new value to an array:This requirement is not fulfilled when array contains empty slots. For example
returns
Which is not correct according to specification, since specified index
2
(from"path": "/2"
) is greater than the number of the elements in the array["a"]
, which is1
.It sounds reasonable to censore empty slots in array to
null
, to be aligned withJSON.stringify()
behaviour. So, the example above should return: