I have the next json
{
"Perfiles": [{
"Nombre":"Default",
"E/S": {
"EntradaHr": 6.45,
"SalidaHr": 12.15
}
}]
}
And the following code
#include <QJsonDocument>
#include <QFile>
#include <QDebug>
#include <QJsonObject>
#include <QJsonArray>
int main(int argc, char *argv[]){
QFile jsonFile("miJson.json");
jsonFile.open(QIODevice::ReadOnly | QIODevice::Text);
QByteArray jsonFileData = jsonFile.readAll();
jsonFile.close();
QJsonDocument document = QJsonDocument::fromJson(jsonFileData);
QJsonObject object = document.object();
QJsonValue value = object.value("Perfiles");
qDebug() << "Value => " << value;
QJsonArray array = value.toArray();
qDebug() << "Array => " << array;
QJsonObject e_sObj = object["E/S"].toObject();
qDebug() << "E/s Object => " << e_sObj;
qDebug() << "Object value => " << object.value("E/S");
auto entradaHr = e_sObj["EntradaHr"];
qDebug() << "Hora entrada => " << entradaHr;
return 0;
}
I can not access object E/S
"E/S": {
"EntradaHr": 6.45,
"SalidaHr": 12.15
}
My question is how could I access it?