Closed bmcustodio closed 7 years ago
I may be wrong, but can't you get the number from JSON as a String:
Double.toString(config.getDouble("key", 2.0));
That's said, we can add an option to the Env and Sys config stores to not parse the content (read all entries as String). Something like `'json-conversion': false'
@cescoffier that wouldn't work—you may end up with something like "4.31543975932E11"
. Even if it wasn't the case, that would only work as long as the value stored in the envvar doesn't overflow (I'm thinking of big numerical strings).
@brunomcustodio if the string representation is not a valid Java double, it will be added as a String to the json object.
@cescoffier yes, I know, but I was talking specifically about your snippet :-)
IMHO we can continue discussing this on #17.
The
EnvVariablesConfigStore
attempts a number of conversions on the values of envvar values before making them available to theconfig.getXXX
methods. For instance, if I defineas one of my environment variables it will end up in
config()
as aDouble
instead of aString
. This happens becauseEnvVariablesConfigStore
usesJsonObjectHelper#put
on the set of envvars. However, sometimes all you need are the "raw" string values. Also, if you are later querying these with methods likeconfig().getDouble()
andconfig().getString()
, I see little to no point in this behaviour—config().getString("CLIENT_ID")
will throw in this use case.Could we get one of the following?
EnvVariablesConfigStore
not useJsonObjectHelper#put
and get raw values inconfig()
.RawEnvVariablesConfigStore
in order not to break any existing code out there and still get raw values inconfig()
?In any of the cases, would you consider a PR?