tupelo.parse
Utils for parsing string values. Provides a thin Clojure wrapper around java native
parsing functions such as java.lang.Float/parseFloat. Unlike the original java
functions, these native-Clojure functions can be used as higher-order functions in maps,
function arguments, etc. Each function also provides an optional default-value which
will be returned if there is an exception during parsing.
edn-parsible
(edn-parsible data)
Traverses a data structure to ensure it can be serialized with `pr-str` and read via
clojure.tools.reader.edn/read-string. All non-parsible content is replaced
with `::non-parsible-object`.
parse-byte
(parse-byte str-val & opts)
(parse-byte str-val )
(parse-byte str-val :default default-val )
A thin wrapper around java.lang.Byte/parseByte. Parses the string str-val into a byte.
If the optional default-val is specified, it will be returned in the event of an
exception.
parse-decimal
(parse-decimal str-val)
(parse-decimal opts str-val)
Inputs: ([str-val :- s/Str] [opts :- tsk/KeyMap str-val :- s/Str])
A thin wrapper around java.math/BigDecimal(String value). Parses the string str-val into a BigDecimal.
An optional default value may be specified in the opts map; is present, it will be returned in the event of an exception.
parse-double
(parse-double str-val & opts)
(parse-double str-val
(parse-double str-val :default default-val )
A thin wrapper around java.lang.Double/parseDouble. Parses the string str-val into a double.
If the optional default-val is specified, it will be returned in the event of an
exception.
parse-float
(parse-float str-val & opts)
(parse-float str-val
(parse-float str-val :default default-val )
A thin wrapper around java.lang.Float/parseFloat. Parses the string str-val into a float.
If the optional default-val is specified, it will be returned in the event of an
exception.
parse-int
(parse-int str-val & opts)
(parse-int str-val)
(parse-int str-val :default default-val )
A thin wrapper around java.lang.Integer/parseInt Parses the string str-val into a integer.
If the optional default-val is specified, it will be returned in the event of an
exception.
parse-long
(parse-long str-val & opts)
(parse-long str-val)
(parse-long str-val :default default-val )
A thin wrapper around java.lang.Long/parseLong. Parses the string str-val into a long.
If the optional default-val is specified, it will be returned in the event of an
exception.
parse-short
(parse-short str-val & opts)
(parse-short str-val)
(parse-short str-val :default default-val )
A thin wrapper around java.lang.Short/parseShort. Parses the string str-val into a short.
If the optional default-val is specified, it will be returned in the event of an
exception.