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
4
4
5
5
## Usage
6
6
7
- $ java -jar json-diff-0.1.1 .jar file1.json file2.json
7
+ $ java -jar json-diff.jar file1.json file2.json
8
8
9
9
## License
10
10
Original file line number Diff line number Diff line change 1
- (defproject json-diff " 0.1.1 "
1
+ (defproject json-diff " 0.2.0 "
2
2
:description " A console program to produce colorized diff of two JSON files"
3
3
:url " https://github.com/reflechant/json-diff"
4
4
: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 1
1
(ns json-diff.core
2
2
(:require [clojure.data.json :as json]
3
- ; ; [clojure.core.async :as async ]
3
+ [clojure.core.async :refer [>! <!! go chan] ]
4
4
[lambdaisland.deep-diff2 :as ddiff]
5
5
[clojure.java.io :as io])
6
6
(:gen-class ))
7
7
8
8
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
+
9
15
(defn diff
10
16
" returns diff between JSON files"
11
17
[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 ))))
17
23
18
24
(defn -main
19
25
" Main function"
20
26
[& args]
21
27
(if (> 2 (count args))
22
28
(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