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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> So, do you have a suggestion?

I do, and it's buried in there:

>> Case 1 just seems wrong.  The "add" in 1a should be an error, and then
>> life would make sense.

Turning that into a text suggestion, it would be this (which
represents a change to the protocol, so the working group would have
to accept it):

OLD
   When the operation is applied, the target location MUST reference one
   of:

   o  The root of the target document - whereupon the specified value
      becomes the entire content of the target document.

   o  A member to add to an existing object - whereupon the supplied
      value is added to that object at the indicated location.  If the
      member already exists, it is replaced by the specified value.
NEW
   When the operation is applied, the target location MUST reference one
   of:

   o  A member to add to an existing object - whereupon the supplied
      value is added to that object at the indicated location.  It is an error
      for the specified member to already exist.
END

OLD
   For example, "add"ing to the path "/a/b" to this document:

   { "a": { "foo": 1 } }

   is not an error, because "a" exists, and "b" will be added to its
   value.  It is an error in this document:

   { "q": { "bar": 2 } }

   because "a" does not exist.
NEW
   For example, given the following starting document:

   { "a": { "foo": 1 } }

   o  "add"ing to the path "/a/b" is not an error, because "/a" exists,
      and "b" will be added to its value.

   o  "add"ing to the path "/q/b" is an error, because "/q" does not
      exist.  But "/q" can be added first, followed by "add"ing "/q/b".

   o  "add"ing to the path "/a" or "/a/foo" is an error, because "/a"
      and "/a/foo" both exist already, and cannot be added.
END

I understand that this will change implementations -- patches that
used to use "add" will now have to use "replace", and there's now no
way to do "add this if it's not already there, and replace it if it is
already there".  Perhaps there's a need to add something with those
semantics.  On the other hand, as the text stands now, there's no way
to do "add this only if it's not already there", because "test" can't
test for existence.

Barry


[Index of Archives]     [IETF Annoucements]     [IETF]     [IP Storage]     [Yosemite News]     [Linux SCTP]     [Linux Newbies]     [Fedora Users]