ietf
[Top] [All Lists]

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

2012-12-16 22:00:31

On 15/12/2012, at 4:27 AM, David J. Biesack 
<David(_dot_)Biesack(_at_)sas(_dot_)com> wrote:


Can one add elements of array to an array? 

E.g. given the document

{ "a" : { "b" : [ "red", "green" ] } }

If I want to add two values to an existing array, I can use

[
{ "op": "add", "path": "/a/b/-", "value": "blue" },
{ "op": "add", "path": "/a/b/-", "value": "yellow" }
]

(I found in the examples how an array index is specified in the path, not in 
a separate "index" member;
I guess my comments there should be directed at 
draft-ietf-appsawg-json-pointer-06 )

However, for appending to arrays, I would like to use

[ { "op": "add", "path": "/a/b/-", "value": [ "blue", "yellow" ] } ]

Reading the spec literally, I expect that this will yield

{ "a" : { "b" : [ "red", "green", [ "blue", "yellow" ] ] } }

Exactly.

instead of the desired

{ "a" : { "b" : [ "red", "green", "blue", "yellow" ] } }

I suggest the semantics of this case should be explicit, to avoid unexpected 
surprises.

I've added an example to clarify this; thanks.



--
Mark Nottingham   http://www.mnot.net/




<Prev in Thread] Current Thread [Next in Thread>