ich würde gerne wissen wo hier mein Denkfehler liegt.
Ich habe eine Json Datei die ich über eine URL bekomme.
Diese hat X Zeilen die alle in der Notation sind:
[{"MMSI":218649000,"TIME":"2014-10-08 09:12:08 GMT","LONGITUDE":7.36065,"LATITUDE":54.14865,"COG":91.2,"SOG":13.3,"HEADING":93,"NAVSTAT":0,"IMO":9105140,"NAME":"ISARSTERN","CALLSIGN":"DQQC","TYPE":89,"A":11,"B":150,"C":12,"D":12,"DRAUGHT":6.1,"DEST":"ELBE","ETA":"10-08 12:00"},{"MMSI":220181000,"TIME":"2014-10-08 09:11:17 GMT","LONGITUDE":8.42678,"LATITUDE":55.47305,"COG":77.6,"SOG":0,"HEADING":331,"NAVSTAT":7,"IMO":0,"NAME":"L217 SDR.NISSUM","CALLSIGN":"","TYPE":30,"A":13,"B":4,"C":2,"D":2,"DRAUGHT":2.5,"DEST":"HVIDE SANDE","ETA":"01-01 00:00"}
reply ist eine QNetworkReply.
Code: Alles auswählen
QJson::Parser parser;
bool ok = true;
QVariant result = parser.parse(reply,&ok);
QVariantMap results = parser.parse (reply, &ok).toMap();
if (!ok) {
qFatal("An error occurred during parsing");
exit (1);
}
qDebug() << "encoding:" << results["MMSI"].toString();
qDebug() << "encoding:" << results["TIME"].toString();
qDebug() << "encoding:" << results["LONGITUDE"].toString();
qDebug() << "encoding:" << results["LATITUDE"].toString();
qDebug() << "encoding:" << results["NAME"].toString();
qDebug() << "encoding:" << results["CALLSIGN"].toString();
qDebug() << "encoding:" << results["DEST"].toString();