witnet-rust
witnet-rust copied to clipboard
Error when parsing floats with commas
Source: [https://www.chards.co.uk/data/update-prices?full=false¤cy=eur]
Script:
const chards = new Witnet.Source("https://www.chards.co.uk/data/update-prices?full=false¤cy=eur")
.parseMapJSON()
.getMap("gold")
.getFloat("gram")
.multiply(1000)
.round()
Error:
RadError
cannot be converted toRadonError
but it should, because it is needed for the tally result. Message: None. Inner:Some(ParseFloat { message: "invalid float literal" })
That's not supported, a simple workaround would be to String.replace(",", "")
That's not supported, a simple workaround would be to
String.replace(",", "")
If we only had a .replace
RADON method...
@aesedepece Would it make sense to have a getFloat RADON function that allows to specify thousand and decimal separators for greater parsing flexibility? Example getFloat("gram", thousand=" ", decimal=",")
for a number 111 111,111
.
Could we create a WIP for this? @tmpolaczyk @lrubiorod
We could
Yes, we could
This was solved by #2235, now about to be released inside 1.6 as per WIP-0024.