File tree Expand file tree Collapse file tree 3 files changed +18
-11
lines changed
Expand file tree Collapse file tree 3 files changed +18
-11
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ A console program to produce colorized diff of two JSON files
44
55## Usage
66
7- $ java -jar json-diff-0.1.1 .jar file1.json file2.json
7+ $ java -jar json-diff.jar file1.json file2.json
88
99## License
1010
Original file line number Diff line number Diff line change 1- (defproject json-diff " 0.1.1 "
1+ (defproject json-diff " 0.2.0 "
22 :description " A console program to produce colorized diff of two JSON files"
33 :url " https://github.com/reflechant/json-diff"
44 :license {:name " EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
Original file line number Diff line number Diff line change 11(ns json-diff.core
22 (:require [clojure.data.json :as json]
3- ; ; [clojure.core.async :as async ]
3+ [clojure.core.async :refer [>! <!! go chan] ]
44 [lambdaisland.deep-diff2 :as ddiff]
55 [clojure.java.io :as io])
66 (:gen-class ))
77
88
9+ (defn open-parse
10+ " open JSON file and parses it"
11+ [fn ]
12+ (with-open [f (io/reader fn )]
13+ (json/read f)))
14+
915(defn diff
1016 " returns diff between JSON files"
1117 [fn1 fn2]
12- (with-open [file1 ( io/reader fn1 )
13- file2 ( io/reader fn2 )]
14- (let [json1 ( json/read file1 )
15- json2 ( json/read file2)]
16- (ddiff/diff json1 json2 ))))
18+ (let [c1 ( chan )
19+ c2 ( chan )]
20+ (go ( >! c1 ( open-parse fn1)) )
21+ ( go ( >! c2 ( open-parse fn2)))
22+ (ddiff/diff ( <!! c1) ( <!! c2 ))))
1723
1824(defn -main
1925 " Main function"
2026 [& args]
2127 (if (> 2 (count args))
2228 (println " Not enough parameters!" )
23- (let [fn1 (first args)
24- fn2 (second args)]
25- (ddiff/pretty-print (diff fn1 fn2)))))
29+ (ddiff/pretty-print
30+ (diff
31+ (first args)
32+ (second args)))))
You can’t perform that action at this time.
0 commit comments