[Qt-interest] Parsing JSON with QT using standard QT library dosn't work
Bradley Smith
bradley at baysmith.com
Sat Mar 27 10:06:44 CET 2010
The http_response is being seen as a block of statements rather than
an object literal. It needs to be put into an expression. Try the
following code.
QString http_response =
"{\"key\":\"a99fdd865c2-10000\",\"oid\":1000055,\"expires
\":0000,\"secret\" :\"509c03edfdc7\",\"sign\":\"f0dd9e5226d0e77\"}";
QScriptValue sc;
QScriptEngine engine;
sc = engine.evaluate("value = " + http_response);
QScriptValueIterator it(sc);
while (it.hasNext()) {
it.next();
qDebug() << it.name() << ": " << it.value().toString();
}
More information about the Qt-interest-old
mailing list