Click here to Skip to main content
15,902,299 members

Comments by Oine 73 (Top 1 by date)

Oine 73 21-Nov-21 13:07pm View    
When i use this code:
QJsonObject obj = doc.object();
qDebug() << obj;
QJsonValue value = obj.value(QString("_quote"));
qDebug() << obj.value(QString("_quote"));;
qDebug() << "Bid value is" << value.toString();;

it makes whole document as an object and then takes value from it but "_quote" isn't in main root of document, so after that in application output it gives: QJsonValue (undefined).

That's why i've made:
auto rootObj = doc.object();
auto _d = rootObj.value("_d").toArray();
auto _t = _d[0].toObject().value("_t").toArray();
auto _quote = _t[0].toObject().value(QString("_quote"));
qDebug() << _quote;

to get value from specified line: obj._d[0]._t[0]._quote of html and it gives
QJsonValue(string, "2248.18")
Now i would like to have output: Bid value is: 2248.18
Do you know what i should do?