Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

something like this should get you going:

struct data {
    float a,b,c;
};

int main(int argc, char** argv)
{
    vector<vector<data> > D; // use a dynamic container
    FileStorage fs("x.json", 0);
    FileNode root = fs["points"];
    for (int i=0; i<root.size(); i++) {
        FileNode val1 = root[i]["val1"]; // we only want the content of val1
        vector<data> row;
        for (int j=0; j<val1.size(); j+=3) { // read 3 consecutive values
            data  d; 
            d.a = val1[j].real();
            d.b = val1[j+1].real();
            d.c = val1[j+2].real();
            row.push_back(d);
        }
        D.push_back(row);
    }
    ....