daviddpark / clj-json-patch Goto Github PK
View Code? Open in Web Editor NEWClojure implementation of http://tools.ietf.org/html/rfc6902
License: Eclipse Public License 1.0
Clojure implementation of http://tools.ietf.org/html/rfc6902
License: Eclipse Public License 1.0
I'm currently unable to apply patches on booleans. I assume this is a valid use-case as I see it done in other json-patch examples.
repl=> (clj-json-patch.core/patch {"enabled" false} [{"op" "replace", "path" "/enabled", "value" true}])
Exception Can't replace a value that does not exist at '/enabled'. clj-json-patch.util/replace-patch-value (util.clj:165)
Example:
Consider these 2 objects:
(def obj1 {"nested" {"foo" "bar"}})
(def obj2 {"nested" {"foo" "bar"
"zot" "baz"}})
diff
works as expected:
(diff obj1 obj2)
=> [{"value" "baz", "op" "add", "path" "/nested/zot"}]
But patch
throws an exception:
(patch obj1 (diff obj1 obj2))
Exception Unable to set value at '/nested/zot'. Consider adding a more explicit data structure as a child of an existing object. clj-json-patch.util/add-patch-value (util.clj:131)
This is similar to #4
(def obj {"array" [{"id" "hello"}]})
(def ops [{"op" "add" "path" "/array/0/foo" "value" "bar"}])
(patch/patch obj ops)
actual:
=> {"array" [{"id" "hello", "foo" "bar"} {"id" "hello"}]}
expected:
=> {"array" [{"id" "hello", "foo" "bar"}]}
Hi, is there any plans for releasing a clojurescript version of this library?
I'm actually interested of using with mori from plain javascript. Any suggestion?
cheers.
Example:
(def obj {"array" [{"name" "item1" "foo" "bar"}
{"name" "item2" "foo" "bar"}]})
(def ops [{"op" "remove" "path" "/array/0/foo"}])
(clojure.pprint/pprint (patch obj ops))
Actual:
{"array"
[{"name" "item1"}
{"name" "item1" "foo" "bar"}
{"name" "item2" "foo" "bar"}]}
Expected:
{"array"
[{"name" "item1"}
{"name" "item2", "foo" "bar"}]}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.