Hi all, I want to access specific elements in a vector of maps. I tried to loop using a for_each like this;
usind namespace std; for (auto ptr : vector< map < string, string> >(pt,"NTESTCASES")) BOOST_FOREACH(boost::property_tree::ptree::value_type &v, pt.get_child("TESTCASES.")) { cout << v.second.data() << endl; }
but i got nothing in the console output. This my JSON file format { "NTESTCASES": 6, "TESTCASES": { "i1_WR_INPUT": { "TYPE": "MUX", "ACTION": "MuxWrInput", "MCU": "STB-ECU", "DATA": "EXT_VBAT_SUPPLY_1K5_1M", "DATA1": "TcClutch_C3.23", "DATA2": "Enable", "ENABLED": "ON", "PINOUT": "" } }, { "i2_HST_DLY": { "TYPE": "SYSTEM", "ACTION": "SysHstDly", "MCU": "BCM-ECU", "DATA": "10", "ENABLED": "ON", "PINOUT": "" } }, { "i3_RD_PIN": { "TYPE": "GPI", "ACTION": "GpiRdPin", "MCU": "BCM-ECU", "NAME": "DiTcClutch", "EXPECTEDDATA": "1", "ENABLED": "ON", "PINOUT": "" } }, { "i4_WR_INPUT": { "TYPE": "MUX", "ACTION": "MuxWrInput", "MCU": "STB-ECU", "DATA": "GND1", "DATA1": "TcClutch_C3.23", "DATA2": "Enable", "ENABLED": "ON", "PINOUT": "" } }, { "i5_HST_DLY": { "TYPE": "SYSTEM", "ACTION": "SysHstDly", "MCU": "BCM-ECU", "DATA": "10", "ENABLED": "ON", "PINOUT": "" } }, { "i6_RD_PIN": { "TYPE": "GPI", "ACTION": "GpiRdPin", "MCU": "BCM-ECU", "NAME": "DiTcClutch", "EXPECTEDDATA": "0", "ENABLED": "ON", "PINOUT": "" } } } thanks for help.
Log in to post a comment.
Hi all,
I want to access specific elements in a vector of maps. I tried to loop using a for_each like this;
but i got nothing in the console output. This my JSON file format
{
"NTESTCASES": 6,
"TESTCASES":
{
"i1_WR_INPUT": {
"TYPE": "MUX",
"ACTION": "MuxWrInput",
"MCU": "STB-ECU",
"DATA": "EXT_VBAT_SUPPLY_1K5_1M",
"DATA1": "TcClutch_C3.23",
"DATA2": "Enable",
"ENABLED": "ON",
"PINOUT": ""
}
},
{
"i2_HST_DLY": {
"TYPE": "SYSTEM",
"ACTION": "SysHstDly",
"MCU": "BCM-ECU",
"DATA": "10",
"ENABLED": "ON",
"PINOUT": ""
}
},
{
"i3_RD_PIN": {
"TYPE": "GPI",
"ACTION": "GpiRdPin",
"MCU": "BCM-ECU",
"NAME": "DiTcClutch",
"EXPECTEDDATA": "1",
"ENABLED": "ON",
"PINOUT": ""
}
},
{
"i4_WR_INPUT": {
"TYPE": "MUX",
"ACTION": "MuxWrInput",
"MCU": "STB-ECU",
"DATA": "GND1",
"DATA1": "TcClutch_C3.23",
"DATA2": "Enable",
"ENABLED": "ON",
"PINOUT": ""
}
},
{
"i5_HST_DLY": {
"TYPE": "SYSTEM",
"ACTION": "SysHstDly",
"MCU": "BCM-ECU",
"DATA": "10",
"ENABLED": "ON",
"PINOUT": ""
}
},
{
"i6_RD_PIN": {
"TYPE": "GPI",
"ACTION": "GpiRdPin",
"MCU": "BCM-ECU",
"NAME": "DiTcClutch",
"EXPECTEDDATA": "0",
"ENABLED": "ON",
"PINOUT": ""
}
}
}
thanks for help.