I'm trying to write data to JSON file with this code.
{ QJsonObject dataIndex; QString filename = QFileDialog::getSaveFileName(this, tr("Flugweg spreichern"), "", tr("Wegpunkt Datei (*.wpf)")); QFile file(filename); for(int i = 0; i < MapView->waypointData.size(); i++){ dataIndex.insert(QString("waypoint00%1").arg(MapView->waypointData[i].iD), QString("%1, %2, %3").arg(MapView->waypointData[i].lng, 0, 'f', 5).arg(MapView->waypointData[i].lat, 0, 'f', 5).arg(MapView->waypointData[i].alt, 0, 'f', 5)); } file.open(QIODevice::WriteOnly); QJsonDocument json_doc(dataIndex); QString json_string = json_doc.toJson(); QFile save_file(filename); if(!save_file.open(QIODevice::WriteOnly)){ qDebug() << "failed to open save file"; } save_file.write(json_string.toLocal8Bit()); save_file.close(); } I get this conclusion:
{ "waypoint000": "10.14200, 52.99339, 0.00000", "waypoint001": "10.15273, 52.99664, 0.00000", "waypoint0010": "10.17547, 52.98598, 0.00000", "waypoint0011": "10.17605, 52.98421, 0.00000", "waypoint0012": "10.17597, 52.98104, 0.00000", "waypoint0013": "10.17561, 52.97992, 0.00000", "waypoint0014": "10.17389, 52.97810, 0.00000", "waypoint0015": "10.17194, 52.97723, 0.00000", "waypoint0016": "10.16719, 52.97632, 0.00000", "waypoint0017": "10.15920, 52.97585, 0.00000", "waypoint0018": "10.15561, 52.97572, 0.00000", "waypoint002": "10.15971, 52.99664, 0.00000", "waypoint003": "10.16554, 52.99577, 0.00000", "waypoint004": "10.16928, 52.99421, 0.00000", "waypoint005": "10.17058, 52.99326, 0.00000", "waypoint006": "10.17130, 52.99235, 0.00000", "waypoint007": "10.17288, 52.99053, 0.00000", "waypoint008": "10.17389, 52.98949, 0.00000", "waypoint009": "10.17453, 52.98819, 0.00000", "waypoint0099": "10.14107, 52.97970, 0.00000" } How to force JSON save 0010, after 009? I read that there is no such sorting in JSON.