Archived Forum Post

Index of archived forum posts

Question:

JSON API support for double (floating point) numbers?

Dec 07 '16 at 11:12

While you’re looking at the JSON object, have I missed something or is there no support for all of the Number data types? This is defined as a double precision floating point format, and has three sub types of Integer, Fraction, and Exponent, but the Chilkat object only appears to support the Integer format via IntAt for reading (there is support for writing numbers using AddNumberAt). Or is the only way to handle this to use strings? I’ve got a requirement to be able to read decimal numbers from an existing JSON object but I’m having to work around this by reading as a string and then converting to a number.


Answer

You app should read the value as a string and then convert to the numeric type using the string-->double conversion offered by your programming language.

Any JSON value type (such as boolean, integer, double, etc.) can be retrieved as a string using the StringAt or StringOf methods.