I have an existing json structure, and I'm trying to add a 2D array of doubles to a new Value in the json tree. Here's the function showing what I've tried to do, with the commented out option of defining a <vector>
instead of a 2D array of doubles (both types give me the same incorrect output):
bool My_class::input_2D_array (Value& object_list, geom_object *obj_f) {
Value v;
// n_verts is the number of "vertices[]" in the for loop below
double vert_list[obj_f->n_verts][3];
//std::vector<std::array<double, 3>> vert_list(obj_f->n_verts);
for(int i=0; i < obj_f->n_verts; i++) {
vert_list[i][0] = obj_f->vertices[i]->x;
vert_list[i][1] = obj_f->vertices[i]->y;
vert_list[i][2] = obj_f->vertices[i]->z;
}
v["vertex_list"] = vert_list;
//v["vertex_list"] = vert_list.data();
object_list.append(v);
return true;
}
This is what the output is:
"object_list" :
{
"vertex_list" : true
}
And this is what I'd like the output to be:
"object_list" :
{
"vertex_list": [
[
0.0,
0.0,
-0.625
],
[
0.4522545635700226,
-0.32857829332351685,
-0.2795122265815735
],
[
-0.17274247109889984,
-0.5316557288169861,
-0.2795124053955078
]
]
}
What am I missing here?