June 2015
Intermediate to advanced
192 pages
4h 8m
English
The QJsonDocument class also has the toJson method, which converts the object it's referencing to JSON.
Here's an example that converts from JSON and back to JSON, pretty-printing the JSON along the way:
QString json = "{ 'call': 'kf6gpe-7', 'lat': 37.40150, 'lng': -122.03683, 'result': 'ok'}";
QJsonDocument document = QJsonDocument.fromJson(json);
QJsonObject data = document.object;
QByteArrayprettyPrintedJson =
document.toJson(QJsonDocumented::Indented); The QJsonDocument class has a method, toJson, which converts the document or array it's referencing to JSON. You can ask for a pretty-printed version of the JSON by passing QJsonDocument::Indented, or a compact version of the JSON by passing ...
Read now
Unlock full access