Xbase++ Requires Chilkat v11.4.0+
Xbase++
Example: JsonObject.NewArrayOf method
See more JSON Examples
Demonstrates theNewArrayOf method.
Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL cBig_cats
LOCAL oJson
nSuccess := 0
cBig_cats := '["lion","tiger","leopard","jaguar","cheetah","snow leopard","clouded leopard","cougar","puma","panther"]'
oJson := CreateObject("Chilkat.JsonObject")
oJson:UpdateString("test", "abc")
nSuccess := oJson:NewArrayOf("big_cats", cBig_cats)
IF (nSuccess == 0)
? oJson:LastErrorText
oJson:destroy()
RETURN
ENDIF
oJson:EmitCompact := 0
? oJson:Emit()
// Result:
// {
// "test": "abc",
// "big_cats": [
// "lion",
// "tiger",
// "leopard",
// "jaguar",
// "cheetah",
// "snow leopard",
// "clouded leopard",
// "cougar",
// "puma",
// "panther"
// ]
// }
oJson:destroy()