Results 1 to 6 of 6

Thread: parsing JSON format

  1. #1
    Join Date
    May 2008
    Posts
    12
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default parsing JSON format

    Hi all,

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

  2. #2
    Join Date
    Jul 2009
    Posts
    1
    Thanks
    1

    Default Re: parsing JSON format

    Hi.
    I want to know, either. Can somebody tell us how to do?
    thx

  3. #3
    Join Date
    Oct 2008
    Posts
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: parsing JSON format


  4. #4
    Join Date
    Jan 2010
    Posts
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4

    Default Re: parsing JSON format

    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();
    }

  5. #5
    Join Date
    Oct 2009
    Location
    Mexico
    Posts
    81
    Thanks
    6
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: parsing JSON format

    try the QJson library, to parse JSON. very useful.

    http://flavio.castelli.name/qjson_qt_json_library

  6. The following user says thank you to ecanela for this useful post:

    Girija (13th September 2010)

  7. #6
    Join Date
    Jun 2010
    Posts
    15
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: parsing JSON format

    Quote Originally Posted by gurmukh View Post
    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
    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!

  8. The following user says thank you to Nickolay for this useful post:

    Girija (13th September 2010)

Similar Threads

  1. Is there a known problem with QMimeData on Mac OS X?
    By Wurgl in forum Qt Programming
    Replies: 8
    Last Post: 27th February 2008, 23:21
  2. Some very weird compilation warnings
    By MarkoSan in forum Qt Programming
    Replies: 21
    Last Post: 23rd January 2008, 17:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.