PureBasic
PureBasic
JSON Insert Empty Array or Object
See more JSON Examples
Demonstrates how to use the UpdateNewArray and UpdateNewObject methods to insert an empty array or object.Note: The UpdateNewArray an UpdateNewObject methods were introduced in Chilkat v9.5.0.75.
Chilkat PureBasic Downloads
IncludeFile "CkJsonObject.pb"
Procedure ChilkatExample()
success.i = 0
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; The following code builds the following JSON, which contains both an empty array and empty object:
; {
; "abc": {
; "xyz": [
; {
; "Name": "myName",
; "Description": "description",
; "ScheduleDefinition": "schedule definition",
; "ExceptionScheduleDefinition": "",
; "Attribute": [
; ],
; "SomeEmptyObject": {},
; "token": "token"
; }
; ]
; }
; }
CkJsonObject::ckUpdateString(json,"abc.xyz[0].Name","myName")
CkJsonObject::ckUpdateString(json,"abc.xyz[0].Description","description")
CkJsonObject::ckUpdateString(json,"abc.xyz[0].ScheduleDefinition","schedule definition")
CkJsonObject::ckUpdateString(json,"abc.xyz[0].ExceptionScheduleDefinition","")
CkJsonObject::ckUpdateNewArray(json,"abc.xyz[0].Attribute")
CkJsonObject::ckUpdateNewObject(json,"abc.xyz[0].SomeEmptyObject")
CkJsonObject::ckUpdateString(json,"abc.xyz[0].token","token")
CkJsonObject::setCkEmitCompact(json, 0)
Debug CkJsonObject::ckEmit(json)
CkJsonObject::ckDispose(json)
ProcedureReturn
EndProcedure