This is an example of how to handle an array of JSON objects
#include <stdio.h>
#include <assert.h>
int main(void)
{
obj2["key"] = "value";
std::vector<json::jobject> vec;
vec.push_back(obj1);
vec.push_back(obj2);
example["array"] = vec;
printf(
"%s\n", example.
pretty().c_str());
assert(example["array"].array(0) == obj1);
assert(example["array"].array(1) == obj2);
std::vector<json::jobject> readbackarray = example["array"];
assert(readback1 == obj1);
assert(readback2 == obj2);
}
The class used for manipulating JSON objects and arrays.
Definition: json.h:410
static jobject parse(const char *input)
Parses a serialized JSON string.
Definition: json.cpp:887
std::string pretty(unsigned int indent_level=0) const
Returns a pretty (multi-line indented) serialzed representation of the object or array.
Definition: json.cpp:997