Subject: Re: [art] Question regarding RFC 6902

From: Mark Nottingham <[email-masked]>
Date: Thu, 30 Aug 2018 10:15:48 +1000

Hi Sebastien,

We were trying to keep it as simple as possible at the time.

FWIW, we've been collecting and discussing ideas for future work here:
  https://github.com/json-patch/json-patch2/issues

It might be worth looking through and seeing if one of those meets your use case (and adding one if not).

Cheers,

> On 30 Aug 2018, at 7:55 am, Sebastien Rosset (serosset) <[email-masked]> wrote:
> 
> Paul, Mark,
> When you wrote RFC 6902, did you consider adding support for the conceptual/functional equivalent of JSON Path, such as shown in the example below? I.e. the array element is addressed through some JSON expression instead of a numeric value:
>  
> [
>   { "op": "replace", "path": "/Tags/[Key='Site']", "value": {"Key": "Site", "Value": "Dallas"} }
> ]
>  
> RFC 6902 makes it easy to add, remove, or replace specific elements in an array. This is better compared to RFC 7386 which requires clients to send the entire array. However RFC 6902 requires clients to have knowledge of the array index. For example, the following body may be used to replace array element at index 2:
>  
> [
>   { "op": "replace", "path": "/Tags/2", "value": {"Key": "Site", "Value": "Dallas"} }
> ]
>  
> In practice this means the client must send a GET request to determine the index value. This can become an issue when multiple concurrent clients modify the same REST resource.
> I am aware of the “-“ notation, but this only works when appending elements at the end of an array.
> Thank you.
> Sebastien Rosset
> Distinguished Engineer
> Cisco

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