Skip to content

Commit

Permalink
Merge remote branch 'zkim/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
dakrone committed Nov 7, 2011
2 parents d085c93 + 98ff87b commit b2a7ce7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cheshire/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@
keywords? should be true if keyword keys are needed, the default is false
maps will use strings as keywords."
[^String string & [^Boolean keywords?]]
(parse
(.createJsonParser factory (StringReader. string))
true (or keywords? false) nil))
(when string
(parse
(.createJsonParser factory (StringReader. string))
true (or keywords? false) nil)))

(defn parse-stream
"Returns the Clojure object corresponding to the given reader, reader must
Expand Down
3 changes: 3 additions & 0 deletions test/cheshire/test/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
(json/parse-string
(json/generate-string {"foo" 'clojure.core/map})))))

(deftest test-nil
(is (nil? (json/parse-string nil true))))

(deftest test-parsed-seq
(let [br (BufferedReader. (StringReader. "1\n2\n3\n"))]
(is (= (list 1 2 3) (json/parsed-seq br)))))
Expand Down

0 comments on commit b2a7ce7

Please sign in to comment.