Sample code for 30+ languages & platforms
DataFlex

JSON Add Large Integer or Double

See more JSON Examples

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.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoJson
    Integer iIndex
    Boolean iSuccess
    String sTemp1

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End

    // To add a large integer, use AddNumberAt.

    // (an index of -1 indicates append).
    Move -1 To iIndex
    Get ComAddNumberAt Of hoJson iIndex "bignum" "8239845689346587465826345892644873453634563456" To iSuccess

    // Do the same for a double..
    Get ComAddNumberAt Of hoJson iIndex "double" "-153634.295" To iSuccess

    Set ComEmitCompact Of hoJson To False
    Get ComEmit Of hoJson To sTemp1
    Showln sTemp1

    // Output:

    // 	{
    // 	  "bignum": 8239845689346587465826345892644873453634563456,
    // 	  "double": -153634.295
    // 	}


End_Procedure