Subject: [apps-discuss] Should this patch succeed?

From: Francis Galiegue <[email-masked]>
Date: Tue, 12 Mar 2013 21:03:30 +0100

On Tue, Mar 12, 2013 at 4:44 PM, Francis Galiegue <[email-masked]> wrote:
> On Tue, Mar 12, 2013 at 3:56 PM, Mark Nottingham <[email-masked]> wrote:
>> Test cases are still more than welcome:
>>   https://github.com/json-patch/json-patch-tests
>>

One test reads something akin to this:

[ { "op": "add", "path": "/0", "value": 1 } ]

With input [], it is expected to give output [ 1 ].

However the spec says:

      [... ]The specified index MUST NOT be greater than the
      number of elements in the array.  If the "-" character is used to
      index the end of the array (see [JSON-Pointer]), this has the
      effect of appending the value to the array.

Strictly speaking, here the 0 in "/0" is not strictly greater than the
number of elements but it is an element which does not exist. And it
would seem that "/-" is the recommended approach here.

So, should this patch succeed? Was it the real intent of the text, or
was is meant to be "the specified index MUST refer to an existing
index in the array. If the character is" etc etc?

--
Francis Galiegue, [email-masked]
JSON Schema in Java: http://json-schema-validator.herokuapp.com

---

From: "Paul C. Bryan" <[email-masked]>
Date: Tue, 12 Mar 2013 13:05:46 -0700

Yes, it should succeed.

Before .../- came along, the way to add to end of the array was to
specify an index equal to the number of elements in the array. This is
why it was phrased as such.

Paul