Value of floating in JSONValue

nrgyzer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 21 23:36:05 PDT 2014


On Thursday, 21 August 2014 at 23:29:56 UTC, Idan Arye wrote:
> On Thursday, 21 August 2014 at 23:05:48 UTC, Ali Çehreli wrote:
>> I don't think it is a concern as JSON does not encode types. 
>> It is up to the receiver how to interpret the data. Here is 
>> the output of the program above:
>>
>> {"value":"1.2345678899999998901"}
>>
>> Ali
>
> JSON may not encode the very specific type the language that 
> created it was using, but it does differ between strings and 
> numbers. {"value":"1.2345678899999998901"} is different from 
> {"value":1.2345678899999998901}, virtually any JSON 
> implementation for any language(there might be exceptions - 
> maybe TCL) will parse them to different language constructs, 
> and code that expect one may fail, crash or misbehave when 
> given the other.

That's exactly my problem. The remote PC expects a numeric value
with a precision of up to 6 floating points. So using a string
instead of float would cause an error.


More information about the Digitalmars-d-learn mailing list