OK, I don't have a compiler with me right now, so this may be only approximate, but something like this:
json::value create_point(int x, int y)
{
json::value result;
result[0] = x; // or json::number(x);
result[1] = y; // or json::number(y);
return result;
}
json::value create_polygons()
{
json::value first,second;
first[U("id")] = "1";
second[U("id")] = "2";
json::value pol1;
pol1[0] = create_point(10,20); pol1[1] = create_point(55,50);
pol1[2] = create_point(55,56); pol1[3] = create_point(50,50);
json::value pol2;
pol2[0] = create_point(12,22); pol2[1] = create_point(55,52);
pol2[2] = create_point(55,56); pol2[3] = create_point(51,52);
first[U("poygon")] = pol1;
second[U("poygon")] = pol2;
json::value result;
result[0] = first;
result[1] = second;
return result;
}
The U() macro is to make the string literals platform-independent: two-byte chars on Windows, single-byte chars on other platforms.