(PureBasic) JSON Array AddObjectCopyAt Example
Demonstrates the AddObjectCopyAt function.
Note: This example requires Chilkat v9.5.0.82 or above.
IncludeFile "CkJsonArray.pb"
IncludeFile "CkJsonObject.pb"
Procedure ChilkatExample()
jarr.i = CkJsonArray::ckCreate()
If jarr.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonArray::ckLoad(jarr,"[ 1, 2, 3, 4]")
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoad(json,"{" + Chr(34) + "street" + Chr(34) + ":" + Chr(34) + "1200 Elm St." + Chr(34) + "," + Chr(34) + "city" + Chr(34) + ":" + Chr(34) + "Springfield" + Chr(34) + "," + Chr(34) + "zip" + Chr(34) + ":60606}")
; Copy the contents of json to the array at index 2, making it the 3rd item in the array.
CkJsonArray::ckAddObjectCopyAt(jarr,2,json)
Debug CkJsonArray::ckEmit(jarr)
; Expected output is: [1,2,{"street":"1200 Elm St.","city":"Springfield","zip":60606},3,4]
CkJsonArray::ckDispose(jarr)
CkJsonObject::ckDispose(json)
ProcedureReturn
EndProcedure
|