PDA

View Full Version : QJsonDocument toJson(QJsonDocument::Compact) not working



elmar.wieser
8th January 2015, 15:43
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:



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

ChrisW67
8th January 2015, 20:50
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.

elmar.wieser
9th January 2015, 06:23
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.