I need to sparse a json of this kind with rapidjson :
{
"errors":{},
"id":2326625,
"source_code":"GOOG",
"data":
[
["2010-01-12",-0.010565362832445,-0.010432881793793,-0.010144243731464,-0.017685262281432,-0.3275071624503],
["2010-01-13",-0.036084889870791,-0.016333087890756,-0.024003268530183,-0.0057299789787753,0.33911818660036],
["2010-01-14",0.012849006806501,0.0098673018033346,0.015523616828298,0.0047058823529412,-0.34735779281787],
["2010-01-15",0.013166015223205,-0.0010781671159029,-0.0081756037236783,-0.016698910497913,0.28200124010685]
]
}
To get value of id "source_code" quite simple :
d.Parse<0>(json);
printf("source_code" = %s\n", document["source_code"].GetString());
However i can't succeed to retrieve value of data. For instance, i would like to be able to retrieve "2010-01-12" and "-0.010565362832445" (The two first value of the first array in data).
Do you have any idea ?
Note that "data" is an array of arrays. If you want to retrieve what you said above, try this:
const rapidjson::Value& b = d["data"];
for (rapidjson::SizeType i = 0; i < b.Size(); i++)
{
const rapidjson::Value& c = b[i];
printf("%s \n",c[rapidjson::SizeType(0)]);
printf("%.20f \n",c[rapidjson::SizeType(1)]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With