Liking cljdoc? Tell your friends :D

clj-json-patch

Clojure implementation of JSON Patch as specified in http://tools.ietf.org/html/rfc6902 with support for JSON Pointer https://tools.ietf.org/html/rfc6901

Usage

[clj-json-patch 0.1.8]

;; From some example namespace:
(ns example.namespace
  (:require [clj-json-patch.core :refer :all]))

Generating patches with the diff function

clj-json-patch.core=> (diff {"foo" "bar"} {"foo" ["bar"]})
[{"op" "replace", "path" "/foo", "value" ["bar"]}]

clj-json-patch.core=> (diff {"foo" ["all" "grass" "cows" "eat"]}
                            {"foo" ["all" "cows" "eat" "grass"]})
[{"op" "move", "from" "/foo/1", "path" "/foo/3"}]

Applying patches with the patch function

clj-json-patch.core=> (patch {"foo" "bar"} [{"op" "replace", "path" "/foo", "value" ["bar"]}])
{"foo" ["bar"]}

clj-json-patch.core=> (patch {"foo" ["all" "grass" "cows" "eat"]}
                             [{"op" "move", "from" "/foo/1", "path" "/foo/3"}])
{"foo" ["all" "cows" "eat" "grass"]}

Run Unit Tests

lein midje

Can you improve this documentation? These fine people already did:
David Park & Pyry Koivisto
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close