Skip to content

Commit

Permalink
allow non const bools for key-fn
Browse files Browse the repository at this point in the history
  • Loading branch information
Beau Fabry committed Jan 12, 2017
1 parent 601bdf3 commit 847077d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cheshire/parse.clj
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
(parse* jp key-fn *use-bigdecimals?* array-coerce-fn))))

(defn parse [^JsonParser jp key-fn eof array-coerce-fn]
(let [key-fn (or (if (identical? key-fn true) keyword key-fn) identity)]
(let [key-fn (or (if (and (instance? Boolean key-fn) key-fn) keyword key-fn) identity)]
(.nextToken jp)
(condp identical? (.getCurrentToken jp)
nil
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 @@ -393,3 +393,6 @@

(deftest t-float-encoding
(is (= "{\"foo\":0.01}" (json/encode {:foo (float 0.01)}))))

(deftest t-non-const-bools
(is (= {:a 1} (json/decode "{\"a\": 1}" (Boolean. true)))))

0 comments on commit 847077d

Please sign in to comment.