From 847077d484fdaf4b59f613cf1b00e1b4a98f8722 Mon Sep 17 00:00:00 2001 From: Beau Fabry Date: Wed, 11 Jan 2017 17:08:04 -0800 Subject: [PATCH] allow non const bools for key-fn --- src/cheshire/parse.clj | 2 +- test/cheshire/test/core.clj | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cheshire/parse.clj b/src/cheshire/parse.clj index a882fd63..91411efd 100644 --- a/src/cheshire/parse.clj +++ b/src/cheshire/parse.clj @@ -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 diff --git a/test/cheshire/test/core.clj b/test/cheshire/test/core.clj index b9ba8c4a..f362d94c 100644 --- a/test/cheshire/test/core.clj +++ b/test/cheshire/test/core.clj @@ -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)))))