PDA

View Full Version : parsing JSON format



Raajesh
23rd May 2008, 14:23
Hi all,

How to parse JSON (JavaScript Object Notation) data-interchange format in Qt?
Can somebody give hints on it?
Thanks,
Raajesh

liuminghacker
28th July 2009, 05:12
Hi.
I want to know, either. Can somebody tell us how to do?:)
thx

remdex
4th August 2009, 19:31
Hi,

Everything you need...
http://qtwiki.org/Parsing_JSON_with_QT_using_standard_QT_library

gurmukh
29th January 2010, 14:21
Hi Guys

i been at this for over 3 hours and dont understand why I cannot get it to work. I have done the examples time and time again, but still no luck!

Anyone shed any light to whats going on?

Thanks!!

#include <QtGui/QApplication>
#include <QScriptValue>
#include <QScriptEngine>
#include <QDebug>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QString result = "{\"result\":[1,2,3]}";

QScriptValue sc;
QScriptEngine engine;
sc = engine.evaluate(result);

if (sc.property("result").isArray())
{

QStringList items;
qScriptValueToSequence(sc.property("result"), items);

foreach (QString str, items) {
qDebug() << str.toStdString().c_str();
}

}
else
{
qDebug() << "It's not an array";
}

return a.exec();
}

ecanela
29th January 2010, 21:10
try the QJson library, to parse JSON. very useful.

http://flavio.castelli.name/qjson_qt_json_library

Nickolay
12th September 2010, 00:40
Hi Guys

i been at this for over 3 hours and dont understand why I cannot get it to work. I have done the examples time and time again, but still no luck!

Anyone shed any light to whats going on?

Thanks!!

}

I also be there
Parsing_JSON_with_QT_using_standard_QT_library (http://qtwiki.org/Parsing_JSON_with_QT_using_standard_QT_library)
And of course I think that now I'm quickly copy-paste and all works....
But now 1:39 and I finished ))) My project alive only after install QJson library. Very powerful library. Respect!