(DataFlex) JSON Array AddObjectCopyAt Example
Demonstrates the AddObjectCopyAt function.
Note: This example requires Chilkat v9.5.0.82 or above.
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoJarr
Boolean iSuccess
Variant vJson
Handle hoJson
String sTemp1
Get Create (RefClass(cComChilkatJsonArray)) To hoJarr
If (Not(IsComObjectCreated(hoJarr))) Begin
Send CreateComObject of hoJarr
End
Get ComLoad Of hoJarr "[ 1, 2, 3, 4]" To iSuccess
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComLoad Of hoJson '{"street":"1200 Elm St.","city":"Springfield","zip":60606}' To iSuccess
// Copy the contents of json to the array at index 2, making it the 3rd item in the array.
Get pvComObject of hoJson to vJson
Get ComAddObjectCopyAt Of hoJarr 2 vJson To iSuccess
Get ComEmit Of hoJarr To sTemp1
Showln sTemp1
// Expected output is: [1,2,{"street":"1200 Elm St.","city":"Springfield","zip":60606},3,4]
End_Procedure
|