I have a json object how can I get object name ? I can't have object name it will be sent by server and that way I should get the object names.
{
"success":1,
"return":{
"343152":{//get this object name
"pair":"usd_eur",
"type":"sell",
"amount":1.00000000,
"rate":3.00000000,
"timestamp_created":1342448420,
"status":0
}
"343157":{//get this object name
"pair":"usd_eur",
"type":"sell",
"amount":1.00000000,
"rate":3.00000000,
"timestamp_created":1342448420,
"status":0
}
}
}
Since your post was tagged with qjson, I assume you're using it...
QJson::Parser parser;
bool ok;
QVariantMap result = parser.parse (json, &ok).toMap(); // json is a QByteArray w. the data
QVariantMap returnMap = result["return"].toMap();
// iterate your map to get the names you're interested in.
for(QVariantMap::const_iterator iter = returnMap.begin(); iter != returnMap.end(); ++iter) {
qDebug() << iter.key();
}
// Do whatever you need with yourObj..