News for hackers. Stuff that matters.
Re:What Is JSON Patch? by salil999 on Tuesday May 10, 2022 @02:08AM (#31323990)
Where would this be useful? I am not trying to bring the article down but I'm genuinely interested in knowing where/how people would use this. It seems like just locally modifying a payload would be more efficient?
Re:What Is JSON Patch? by mathgladiator on Tuesday May 10, 2022 @02:13AM (#31324015)
JSON merge ( https://datatracker.ietf.org/doc/html/rfc7386 ) is the entire basis for how I persist document changes to disk and to clients ( http://www.adama-platform.com/2021/03/28/json.html ).

Arrays require some care to handle which is why I'm got some extensions in my client, but a super power that JSON patching enables is that it can be algebraic in nature. That it, we can define a patching which is associative (another extension where you preserve nulls) such that (X + da) + db = X + (da + db) = X + dc where da + db + dc

This allows you to leverage flow control when congestion happens (especially on mobile connections).

Re:What Is JSON Patch? by nigma1337 on Tuesday May 10, 2022 @02:26AM (#31324096)
Using it for k8s currently, in a request like

[{"op": "replace", "path":"/spec/template/metadata/annotations/restarted-at", "value": "'$(date -Iseconds)'"}]

to restart/redeploy.

Re:What Is JSON Patch? by coredog64 on Tuesday May 10, 2022 @09:36AM (#31326960)
Amazon uses this for changes to API Gateway. Take that as either a positive or a negative :)
Re:What Is JSON Patch? by kgeist on Tuesday May 10, 2022 @02:36AM (#31324146)
I can think of realtime collaborative document editing - patches are sent to the server instead of sending the whole JSON-based document every time and the app resolves potential conflicts.
Re:What Is JSON Patch? by chii on Tuesday May 10, 2022 @03:20AM (#31324444)
But i wonder if you have to use a very long pointer expression to identify a single character being typed, you'd end up with much higher overhead.
Re:What Is JSON Patch? by wvh on Tuesday May 10, 2022 @10:44AM (#31327723)
Software such as Kubernetes uses it with different processes writing to the same data fields, but different subsets. If you have a typical API with only one main blob that gets updated in its entirety, you might not avoid conflicts using the PATCH approach.
Re:What Is JSON Patch? by jurple on Tuesday May 10, 2022 @03:10AM (#31324386)
We have a supplier who uses it to distribute daily updates to their (large) product catalog. It helps that most of the mutations are to specific fields like availability and price, while EAN/GTIN etc tend to be stable. Deletions are trivial as well.
Re:What Is JSON Patch? by Hamuko on Tuesday May 10, 2022 @02:10AM (#31323999)
Kustomize patches.
Re:What Is JSON Patch? by EdwardDiego on Tuesday May 10, 2022 @03:10AM (#31324385)
I've used it with K8s and kustomize a fair bit.