(Unicode C) JSON Add Large Integer or Double
Demonstrates how to add a large number (larger than what can be held in an integer), or a double/float value to a JSON document.
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
HCkJsonObjectW json;
int index;
json = CkJsonObjectW_Create();
// To add a large integer, use AddNumberAt.
// (an index of -1 indicates append).
index = -1;
CkJsonObjectW_AddNumberAt(json,index,L"bignum",L"8239845689346587465826345892644873453634563456");
// Do the same for a double..
CkJsonObjectW_AddNumberAt(json,index,L"double",L"-153634.295");
CkJsonObjectW_putEmitCompact(json,FALSE);
wprintf(L"%s\n",CkJsonObjectW_emit(json));
// Output:
// {
// "bignum": 8239845689346587465826345892644873453634563456,
// "double": -153634.295
// }
CkJsonObjectW_Dispose(json);
}
|