diff --git a/README.md b/README.md index 33373ca..c2c38cf 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ `clj-yaml` is available as a Maven artifact from [Clojars](http://clojars.org/clj-yaml): :dependencies - [["clj-yaml" "0.4.0"] + [["clj-yaml" "0.4.1"] ...] ## Development diff --git a/project.clj b/project.clj index 7d41127..39937fd 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject clj-yaml "0.4.0" +(defproject clj-yaml "0.4.1" :description "YAML encoding and decoding for Clojure using SnakeYAML" :url "http://github.com/lancepantz/clj-yaml" :dependencies diff --git a/src/clj_yaml/core.clj b/src/clj_yaml/core.clj index f2c611f..87a6ea9 100644 --- a/src/clj_yaml/core.clj +++ b/src/clj_yaml/core.clj @@ -26,7 +26,9 @@ (decode [data])) (defn decode-key [k] - (if *keywordize* (keyword k) k)) + (if *keywordize* + (or (keyword k) k) ; (keyword k) is nil for numbers and other values + k)) (extend-protocol YAMLCodec diff --git a/test/clj_yaml/core_test.clj b/test/clj_yaml/core_test.clj index e8e7fba..52f91e9 100644 --- a/test/clj_yaml/core_test.clj +++ b/test/clj_yaml/core_test.clj @@ -58,6 +58,14 @@ the-bin: !!binary 0101") (let [parsed (parse-string "foo: bar")] (is (= "bar" (parsed :foo))))) +(deftest parse-hash-with-numeric-key + (let [parsed (parse-string "123: 456")] + (is (= 456 (parsed 123))))) + +(deftest parse-hash-with-complex-key + (let [parsed (parse-string "[1, 2]: 3")] + (is (= 3 (parsed [1, 2]))))) + (deftest parse-nested-hash (let [parsed (parse-string nested-hash-yaml)] (is (= "a" ((parsed :root) :childa))) @@ -118,4 +126,4 @@ the-bin: !!binary 0101") (is (= "- age: 33\n name: jon\n- age: 44\n name: boo\n" (generate-string data :dumper-options {:flow-style :block}))) (is (= "[{age: 33, name: jon}, {age: 44, name: boo}]\n" - (generate-string data :dumper-options {:flow-style :flow}))))) \ No newline at end of file + (generate-string data :dumper-options {:flow-style :flow})))))