Re:JSON Patch – a format for describing changes to a JSON do...
by jasonkostempski on Wednesday October 29, 2014 @11:03PM
(#8531122)
Damn, thought I invented the array path thing :) I love how clear it is to read but my favorite thing is how easy it is to apply it:
I got stuck at indexing as well. I feel like there's a good solution involving using an array element within the path array to denote a selector query of sorts but I haven't hashed it out yet.
[ Parent
| on HN ]
Re:JSON Patch – a format for describing changes to a JSON do...
by afandian on Thursday October 30, 2014 @05:16AM
(#8531994)
If you're interested, this is the general structure and access method of the 'trie' data structure.
http://en.wikipedia.org/wiki/Trie
Also, Clojure has a nice functions called get-in and friends:
user=> (def x {:a 1 :b 'B' :c { :x "X" :y "Y" :z "Z" }
:d [{:p "P"} {:q "Q"} {:r "R"}] })
#'user/x
user=> (get-in x [:d 1 :q])
"Q"
user=> (assoc-in x [:d 1 :q] "QQ")
{:a 1, :c {:z "Z", :y "Y", :x "X"}, :b B', :d [{:p "P"} {:q "QQ"} {:r "R"}]}