JSON examples
Below are some examples of how you can use the JSON conversion methods.
QVariantList to JSON array
QList<QVariant> list; list << 0 << 1 << 2 << 3 << 4 << 5; // output is "[1, 2, 3, 4, 5]" qDebug() << JSON::VariantToJSON( list );
QVariantMap to JSON object
QMap<QString,QVariant>map;
map["zero"] = 0;
map["one"] = 1;
map["two"] = 2;
map["three"] = 3;
map["four"] = 4;
map["five"] = 5;
// output is "{"zero":0, "one":1 ...}"
qDebug() << JSON::VariantToJSON( map );
