C++
C++
Copy JSON Object from one JSON Array to Another
See more JSON Examples
Demonstrates how to copy an object in a JSON array to another JSON array.Chilkat C++ Downloads
#include <CkJsonArray.h>
#include <CkJsonObject.h>
void ChilkatSample(void)
{
CkJsonArray arr1;
CkJsonArray arr2;
const char *s = "[{\"a\":1}, {\"b\":2}, {\"c\":3}]";
const char *sEmpty = "[]";
arr1.Load(s);
arr2.Load(sEmpty);
CkJsonObject jObj;
arr1.ObjectAt2(1,jObj);
arr2.AddObjectCopyAt(-1,jObj);
std::cout << arr2.emit() << "\r\n";
// output is: [{"b":2}]
}