Unicode C
Unicode C
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 Unicode C Downloads
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
BOOL success;
HCkJsonObjectW json;
success = FALSE;
json = CkJsonObjectW_Create();
// 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"
// }
// ]
// }
// }
CkJsonObjectW_UpdateString(json,L"abc.xyz[0].Name",L"myName");
CkJsonObjectW_UpdateString(json,L"abc.xyz[0].Description",L"description");
CkJsonObjectW_UpdateString(json,L"abc.xyz[0].ScheduleDefinition",L"schedule definition");
CkJsonObjectW_UpdateString(json,L"abc.xyz[0].ExceptionScheduleDefinition",L"");
CkJsonObjectW_UpdateNewArray(json,L"abc.xyz[0].Attribute");
CkJsonObjectW_UpdateNewObject(json,L"abc.xyz[0].SomeEmptyObject");
CkJsonObjectW_UpdateString(json,L"abc.xyz[0].token",L"token");
CkJsonObjectW_putEmitCompact(json,FALSE);
wprintf(L"%s\n",CkJsonObjectW_emit(json));
CkJsonObjectW_Dispose(json);
}