Hi Andreas,
Since javascript treats JSON numbers as double-precision floats, it can't represent all CQL bigint and decimal values as javascript Numbers. When converting into JSON, we override the toJSON methods to return the toString representation (
Long,
BigDecimal) as opposed to their object content.
We could change that to return Number in the case that the value can be represented as a Number, and String where it couldn't, but it wouldn't be a complete solution. Eventually you'll encounter a value that cannot be represented as a number, in which case, you'll get a JSON string. I think it is easier for clients to only worry about parsing the value as one type, instead of checking if its a Number or String then do the conversion.
Alternatively, the JSON specification does not define bounds for Number, so you could argue that it might be reasonable to render these values as numbers, but unfortunately I do not think there is a way to achieve this with javascript using JSON.stringify so you would have to come up with a custom solution.
Thanks,
Andy