Skip to content

Commit

Permalink
Add JSON support
Browse files Browse the repository at this point in the history
  • Loading branch information
ToxicFrog committed Dec 12, 2015
1 parent 4655c7c commit c9d0d13
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ You will need to at least specify `--from` and `--to` to specify input and outpu
html* W HTML file that can submit changes to Backloggery
text RW User-editable plain text
edn RW Machine-readable EDN
json RW Machine-readable JSON

* Not yet implemented

Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/core.typed "0.2.5"]
[org.clojure/data.xml "0.0.7"]
[org.clojure/data.json "0.2.5"]
[org.clojure/data.json "0.2.6"]
[org.clojure/tools.cli "0.2.4"]
[clj-http "0.7.6"]
[slingshot "0.10.3"]
Expand Down
1 change: 1 addition & 0 deletions src/bltool/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
html* W HTML file that can submit changes to Backloggery
text RW User-editable plain text
edn RW Machine-readable EDN
json RW Machine-readable JSON
* Not yet implemented"

Expand Down
2 changes: 1 addition & 1 deletion src/bltool/data.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns bltool.data
(:require [bltool.data.default :as default])
(:require [bltool.data steam backloggery edn text xboxlive])
(:require [bltool.data steam backloggery edn text xboxlive json])
(:require [bltool.flags :refer :all]))

(def read-games default/read-games)
Expand Down
13 changes: 13 additions & 0 deletions src/bltool/data/json.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(ns bltool.data.json
(:require [bltool.data.default :refer :all])
(:require [bltool.flags :refer :all])
(:require [clojure.data.json :as json])
(:require [clojure.pprint :as pprint]))

(defmethod read-games "json" [_ source]
(json/read (java.io.PushbackReader. source) :key-fn keyword))

(defmethod write-games "json" [_ games sink]
(binding [*out* sink]
(json/pprint (vec games)))
(.write sink "\n"))

0 comments on commit c9d0d13

Please sign in to comment.