Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

64bit numbers

Elmar
2012-12-06
2013-11-06
  • Elmar
    Elmar
    2012-12-06

    Hi,
    I have to transmit 64 bit integers via JSON.  In C++ the according datatype is e.g. represented by the "long long" (=64bit unsigned int). Is it possible with JSON in general and if yes with this Library to transmit it as a number value
    or is the right way to go to convert the value into a textstring and send it as a string.
    Thanks in advance for your help!!!!

     
  • Yes, use the JSON_INT_TYPE option in the JSONOptions.h.  Switch it to long long

     
  • BabelFish
    BabelFish
    2013-11-06

    We changed the defined but we are running into some problems. The following number will not convert correctly 9187615798948486059. This is on Windows 64Bit.

    const unsigned long long ull = 9187615798948486059;
    const JSONNode jsonNode("example", ull);
    assert( jsonNode.as_int() == ull );

    There are several issues that I see:
    -_uitoa casts to unsigned long
    -storing this value as double (_number) results in truncation

    const unsigned long long ull = 9187615798948486059;
    const double _number = ull;
    const unsigned long long ullReturn = (unsigned long long)_number;
    assert( ullReturn == ull );

    Note that ullReturn equals 9187615798948486144

    Is there an update coming which has an official fix for this issue?

    thanks!

     
    Last edit: BabelFish 2013-11-06