Subject: Re: [apps-discuss] Updated JSON Merge Patch...

From: krisnye <[email-masked]>
Date: Mon, 26 Nov 2012 11:31:18 -0800 (PST)

I independently developed an almost identical solution for simple patches
about a year ago.

The only difference is that I do not special case null.  It is treated like
any other json value.

I use 'undefined' to indicate removal of a value.

There are some advantages and disadvantages to this.

The disadvantage is obviously that undefined is not a valid json value.

The main advantage is that EVERY valid json document now becomes a valid
merge patch object that will create itself if applied to a null object.

It is also useful because we really need to set a null value on some
properties sometimes.  We cannot do it if null is special cased.  For
instance, I want to be able to patch more than just raw json objects.  I
should be able to patch ANY javascript object.  If the javascript object has
a getter/setter defined on a property, then deleting that property does
nothing (and returns false).  If I want the property value to be null, I
must be able to actually set null on it.

Also, you should really note the merge-patch advantage of being inherently
idempotent when compared to JSONPatch which is not inherently idempotent
(but can be made so with use of test op).

I would also recommend noting that you can patch a patch and the operation
is *mostly* associative.

--
View this message in context: http://ietf.10.n7.nabble.com/apps-discuss-Updated-JSON-Merge-Patch-tp340197p347543.html
Sent from the IETF - Discuss mailing list archive at Nabble.com.