QJsonDocument toJson(QJsonDocument::Compact) not working
Hello all,
maybe somebody can help me.
I'm using Qt5.2 and I'm trying to parse QJsonDocument as QString in compact output. But it's not working.
On other systems with eg. Qt5.1 ist working without problems.
Here is my code:
Code:
QJsonObject obj;
obj.insert("test",123);
QJsonDocument jd;
jd.setObject(obj);
qDebug() << "jd.toJson()" ;
qDebug() << jd.toJson();
qDebug() << "jd.toJson(QJsonDocument::Compact)";
qDebug() << jd.toJson(QJsonDocument::Compact);
qDebug() << "jd.toJson(QJsonDocument::Indented)";
qDebug() << jd.toJson(QJsonDocument::Indented);
and the output:
jd.toJson()
"{
"test": 123
}
"
jd.toJson(QJsonDocument::Compact)
/opt/qt_app/bin/qt_app: symbol lookup error: /opt/qt_app/bin/qt_app: undefined symbol: _ZNK13QJsonDocument6toJsonENS_10JsonFormatE
Re: QJsonDocument toJson(QJsonDocument::Compact) not working
That looks like your program is finding a Qt 5.0 library at run time (its version of toJson() does not take an argument). Use ldd in the same environment that the program is being run to determine what libraries it will try to load.
Re: QJsonDocument toJson(QJsonDocument::Compact) not working
That's correct. I found the problem. I'm running the application on a remote system. This remote system was on Qt 5.0.2 and this has only toJson() without arguments.