Unsolved How to search spesific element in JSON file?
-
Here is my Json file.
{ "A":[ { "GPS":[ { "GPS ID":[ "integer", "0" ], "GPS Mod":[ "integer", "1" ], "GPS Utc":[ "float", "2" ], "GPS Latitude":[ "float", "3" ], "GPS Longitude":[ "float", "4" ] } ]
I've read it like that:
```
QByteArray data = file.readAll(); QJsonDocument doc = QJsonDocument::fromJson(data); QJsonObject root = doc.object(); QJsonArray tlmtArray = root.value("Telemetri Verileri").toArray(); for(int i=0; i<tlmtArray.size(); i++) { QJsonObject obj = tlmtArray.at(i).toObject(); // qDebug() << "bakalm okudumu" << obj; QString a= tlmtArray.at(i).toString(); }
How can I print the all values which contains "float"
-
@suslucoder
GPS
holds an array of objects. (It only seems to contain one object in the array, but that's what it's the JSON.) Go through each key in the object. If its value is an array (all of yours are),array[0]
is the "type", so see ifarray[0] == "float"
, and outputarray[1]
if it does.