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

From: "David J. Biesack" <[email-masked]>
Date: Fri, 14 Dec 2012 12:27:32 -0500

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" ] ] } }

instead of the desired

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

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

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

---

From: Mark Nottingham <[email-masked]>
Date: Mon, 17 Dec 2012 15:00:05 +1100

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

Exactly.

> 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/