Sample code for 30+ languages & platforms
DataFlex

JSON Append String Array

See more JSON Examples

Demonstrates how to append an array of strings from a string table object.

Note: This example uses the AppendStringTable method, which was introduced in Chilkat v9.5.0.67

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoJson
    Boolean iSuccess
    Variant vSt
    Handle hoSt
    String sTemp1

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

    Get ComAppendString Of hoJson "abc" "123" To iSuccess

    Get Create (RefClass(cComChilkatStringTable)) To hoSt
    If (Not(IsComObjectCreated(hoSt))) Begin
        Send CreateComObject of hoSt
    End
    Get ComAppend Of hoSt "a" To iSuccess
    Get ComAppend Of hoSt "b" To iSuccess
    Get ComAppend Of hoSt "c" To iSuccess
    Get ComAppend Of hoSt "d" To iSuccess

    Get pvComObject of hoSt to vSt
    Get ComAppendStringArray Of hoJson "strArray" vSt To iSuccess

    Get ComEmit Of hoJson To sTemp1
    Showln sTemp1

    // Output:

    // 	{
    // 	  "abc": "123",
    // 	  "strArray": [
    // 	    "a",
    // 	    "b",
    // 	    "c",
    // 	    "d"
    // 	  ]
    // 	}


End_Procedure