Subject: [Json] Extending JSON Patch (or JSON Pointer) to include indexing into a string

From: Mitar <[email-masked]>
Date: Thu, 3 Oct 2019 23:02:19 -0700

Hi!

I really like JSON Patch with its simplicity, but what I am missing is
that it does not allow expressing a patch to a string itself. So if
you have a long string value (like a text document) and you would like
to describe a patch which modifies a part of such string, currently
you have to provide the whole new string, instead of just a patch to
the string.

So what do people think about supporting a patch (probably by simply
extending JSON Pointer) to allow specifying for JSON like:

{"value": "foobar"}

A patch like:

[
  {"op": "replace", "path": "/value/0-3", "value": "no"}
]

Replacing first three characters with "no' and resulting in:

{"value": "nobar"}

So upper limit would be exclusive. You could also specify "2-" to
select all characters from the 3rd character to the end.

Also, I have no experience with the IETF process on how would one go
about introducing such a change to existing standards.

Mitar

-- 
http://mitar.tnode.com/
https://twitter.com/mitar_m

---

From: "Manger, James" <[email-masked]>
Date: Tue, 8 Oct 2019 04:35:29 +0000

> So what do people think about supporting a patch (probably by simply extending JSON Pointer)

Tacking "/0-3" or "/2-" on the end of a JSON Pointer is a bad idea as it looks like a legitimate JSON Pointer for an object member named "0-3" or "2-". A better approach would be a new "op" value and a new member to hold the range. For example:

  { "op":"string_replace", "path":"/value", "range":"0-3", "value":"no"}

Whether its best to provide a range & value, or old & new substrings, or a regex & replacement, or a line-oriented diff format, ... I'm not sure.

> Also, I have no experience with the IETF process on how would one go about introducing such a change to existing standards.

Perhaps write some code to convince yourself it works well; document it in an independent submission (https://www.rfc-editor.org/about/independent/) called, say, draft-mitar-json-string-patch; and see if any IETF group is interested.

--
James Manger

---

From: Mark Nottingham <[email-masked]>
Date: Tue, 8 Oct 2019 16:07:33 +1100

Also, we're collecting input for possible future revisions / extensions here:
  https://github.com/json-patch/json-patch2/issues

Please feel free to add an issue there.

Cheers,

> On 8 Oct 2019, at 3:35 pm, Manger, James <[email-masked]> wrote:
> 
> _______________________________________________
> json mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/json

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

---

From: Mitar <[email-masked]>
Date: Thu, 10 Oct 2019 23:43:37 +0200

Hi!

Thank you for the reply.

On Tue, Oct 8, 2019 at 6:59 AM Manger, James
<[email-masked]> wrote:
> Tacking "/0-3" or "/2-" on the end of a JSON Pointer is a bad idea as it looks like a legitimate JSON Pointer for an object member named "0-3" or "2-".

Sure, but that hold for regular "/0" as well, no? If there is an
object at / then it is a JSON Pointer for an object member named "0".
But if it is an array, it means accessing a particular element of the
array.

> A better approach would be a new "op" value and a new member to hold the range.

That is an interesting idea as well. I will think about it.

Mitar

---

From: Mitar <[email-masked]>
Date: Sun, 13 Oct 2019 01:07:56 +0200

Hi!

I opened:

https://github.com/json-patch/json-patch2/issues/28

Mitar