C++
C++
Example: JsonObject.NewArrayOf method
See more JSON Examples
Demonstrates theNewArrayOf method.
Chilkat C++ Downloads
#include <CkJsonObject.h>
void ChilkatSample(void)
{
bool success = false;
const char *big_cats = "[\"lion\",\"tiger\",\"leopard\",\"jaguar\",\"cheetah\",\"snow leopard\",\"clouded leopard\",\"cougar\",\"puma\",\"panther\"]";
CkJsonObject json;
json.UpdateString("test","abc");
success = json.NewArrayOf("big_cats",big_cats);
if (success == false) {
std::cout << json.lastErrorText() << "\r\n";
return;
}
json.put_EmitCompact(false);
std::cout << json.emit() << "\r\n";
// Result:
// {
// "test": "abc",
// "big_cats": [
// "lion",
// "tiger",
// "leopard",
// "jaguar",
// "cheetah",
// "snow leopard",
// "clouded leopard",
// "cougar",
// "puma",
// "panther"
// ]
// }
}