Re: Last Call: <draft-ietf-appsawg-json-patch-08.txt> (JSON Patch) to Proposed Standard

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"4.1 add" and "4.2 remove" refers to "specified index", but I do not see name of the index member specified in the draft, or how to represent it.
(Other sections are more explicit, i.e. "from" for the "move" op.)

i.e. "index" as in 

  "index" : integer 

The phrasing 

   If the "-" character is used to index the end of the array, this has the effect of appending the value to the array.

is not clear. Where does this "-" character appear? Does one use just

  "index" : "-" 

in which case the spec should be 

  If the "-" string is used ...

If instead you mean a negative integer, i.e.

  "index" : negative-integer

and not just "-", does the spec interpret all negative integers to indicate appending to the end?

I'd prefer the value not have two separate types, integer vs. string.

Suggestion: allow negative numbers to indicate a position counted from the end of the array i.e. -1 to append, -2 to insert before the last item, and so on. E.g. after appending to an array of length l at i < 0, the item will be at the zero-based index (l + 1) + i. Error if |i| > l

E.g. given the document with an array of length 4:

{ "a" : [ 0, 1, 2, 3, ] }

then 

{ "op" : "add", "path" : "a", "value" : 99, "index" : -1 }

yields

{ "a" : [ 0, 1, 2, 3, 99] }

i.e. 99 is found at (4 + 1) -1 == 4

{ "op" : "add", "path" : "a", "value" : 99, "index" : -2 }

yields

{ "a" : [ 0, 1, 2, 99, 3] }

i.e. 99 is found at (4 + 1) -2 == 3

and finally

{ "op" : "add", "path" : "a", "value" : 99, "index" : -5 }

yields

{ "a" : [ 99, 0, 1, 2,, 3] }

i.e. 99 is found at (4 + 1) -5 == 0

-- 
David J. Biesack | Principal API Architect, SAS | @davidbiesack | 919-531-7771 | www.sas.com



[Index of Archives]     [IETF Annoucements]     [IETF]     [IP Storage]     [Yosemite News]     [Linux SCTP]     [Linux Newbies]     [Fedora Users]