Subject: [apps-discuss] Question about JSON Patch I-D 10, section 4

From: Francis Galiegue <[email-masked]>
Date: Sun, 3 Feb 2013 11:14:25 +0100

Hello,

The beginning of this section says:

> Operation objects MUST have exactly one "op" member, whose value
> indicates the operation to perform.

Well, JSON Patch is written in JSON and RFC 4627 says that JSON
Objects should have unique member names anyway, so why is this
precised here?

--
Francis Galiegue, [email-masked]
Try out your JSON Schemas: http://json-schema-validator.herokuapp.com

---

From: Barry Leiba <[email-masked]>
Date: Sun, 3 Feb 2013 20:52:27 +0900

> Objects should have unique member names anyway, so why is this

Well, first, there's otherwise no requirement for a member named "op",  so
this needs to require that.  Second, 4627 says, "The names within an object
SHOULD be unique," which leaves a possibility that they are not.  Here,
"MUST have exactly one" more strictly specifies this for "op".

Barry

---

From: Francis Galiegue <[email-masked]>
Date: Sun, 3 Feb 2013 13:01:36 +0100

On Sun, Feb 3, 2013 at 12:52 PM, Barry Leiba <[email-masked]> wrote:
[...]
> "MUST have exactly one" more strictly specifies this for "op".

OK, but JSON Patch is a JSON text anyway, and if duplicate member
names are found during parsing, JSON Patch cannot do anything about it
anyway, right?

I mean, it is up to the parser, here, not JSON Patch. For instance,
some parsers will "swallow" duplicates and JSON Patch will only ever
see the member elected by the parser for inclusion. But basically, the
behaviour of the parser in this situation is undefined.

To my eyes, it means that JSON Patch imposes requirements on the
_parser_ that it shouldn't impose. I think specifying "Operations MUST
have a member named 'op'" would be enough.

Thoughts?

---

From: "Markus Lanthaler" <[email-masked]>
Date: Sun, 3 Feb 2013 13:16:52 +0100

> behaviour of the parser in this situation is undefined.

Right. That's exactly the reason why you need to specify it at the format
level. If you don't, the outcome will be nondeterministic as you outlined
above.

> have a member named 'op'" would be enough.

Nope. It imposes requirements on the format so that every parser produces
the same deterministic output.

Cheers,
Markus

--
Markus Lanthaler
@markuslanthaler