diff --git a/README.md b/README.md index 906dce4..42a578c 100644 --- a/README.md +++ b/README.md @@ -170,9 +170,9 @@ can specify multiple hostnames in a set. :default 8082}}} ``` -### long, double, keyword, boolean +### int, long, double, keyword, boolean -Use to parse a `String` value into a `Long`, `Double`, keyword or boolean. +Use to parse a `String` value into a `Integer`, `Long`, `Double`, keyword or boolean. ``` clojure {:debug #boolean #or [#env DEBUG "true"] diff --git a/src/aero/core.cljc b/src/aero/core.cljc index b70b436..260313c 100644 --- a/src/aero/core.cljc +++ b/src/aero/core.cljc @@ -60,6 +60,11 @@ #?(:clj (System/getProperty (str value)) :cljs nil)) +(defmethod reader 'int + [opts tag value] + #?(:clj (Integer/parseInt (str value))) + #?(:cljs (js/parseInt (str value)))) + (defmethod reader 'long [opts tag value] #?(:clj (Long/parseLong (str value))) diff --git a/test/aero/config.edn b/test/aero/config.edn index 5017e88..80d0c24 100644 --- a/test/aero/config.edn +++ b/test/aero/config.edn @@ -14,7 +14,11 @@ :false-boolean #boolean "false" :trivial-false-boolean #boolean "OTHER" :nil-false-boolean #boolean "" + :int-native #int 1234 + :int #int "1234" + :long-native #long 1234 :long #long "1234" + :number 1234 :double #double "4567.8" :keyword #keyword "foo/bar" :already-a-keyword #keyword :foo/bar