convert decimal numbers with trimmed zeros
Currently the "number" function fails on this input: ".25" or "-.25".
Our data provider sends decimal numbers in that format, and so far JSLT is the only technology we use that cannot work with it.
We can work around it padding the string with a missing zero before feeding it into the "number" function.
I think this is a fair point. The documentation of the number() function says it will convert the string into a number "if possible", and it definitely is possible to accept this number.
I checked, and the corresponding functions in Python, JavaScript, and Java all turn ".25" into 0.25. So clearly JSLT should do the same.
With a trailing decimal point, the three mentioned languages have 2 different outcomes.
But then, JS internally only uses floating point numeric type, which "covers" integers.
JS
2 + 3. => 5
Python
2 + 3. => 5.0
Java
2 + 3. => 5.0 Only allowed for assignment to a double; illegal for an int or float
double a = 2 + 3
What do you want to support here ? Treat it as a dobule ?
Sorry for the late response. In this case, I would expect that it treats it as a double. What would be alternative? That it fails on converting the int to a double?
We treat ".25 and "0.25" as the same number, basically. All parsed numbers become DoubleNode in the Jackson representation. The initial zero does not affect the type.
Anyway, this has been fixed now. (Thanks @catull!) It would be great if those who care about this issue could do a little testing with the current code (@azpro). If everything looks OK I can release a new version.