←back to thread

JSON Patch

(zuplo.com)
299 points DataOverload | 1 comments | | HN request time: 0s | source
Show context
scottlu2 ◴[] No.41883652[source]
The article suggests json patch is idempotent, but it isn’t idempotent for array mutations. JSON merge patch on the other hand is fully idempotent (in the array case the array is replaced).
replies(1): >>41883789 #
1. kardos ◴[] No.41883789[source]
Indeed it does not seem idempotent. If you move A to B and insert a new A, then rerunning the patch would yield the new A at B.

I suppose a subset of this is idempotent though.

Broadly this seems fraught with peril. It sounds like edge case upon edge case, and only would work in the narrow case where you are 100% sure exactly what the remote document looks like such that you can calculate the patch. If anything gets out of sync, or serialization differs between local and remote, etc youre going to get subtle bugs...