Results 1 to 3 of 3

Thread: QJsonDocument toJson(QJsonDocument::Compact) not working

  1. #1
    Join Date
    Aug 2013
    Posts
    2
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default 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:

    Qt Code:
    1. QJsonObject obj;
    2. obj.insert("test",123);
    3.  
    4. QJsonDocument jd;
    5. jd.setObject(obj);
    6.  
    7. qDebug() << "jd.toJson()" ;
    8. qDebug() << jd.toJson();
    9. qDebug() << "jd.toJson(QJsonDocument::Compact)";
    10. qDebug() << jd.toJson(QJsonDocument::Compact);
    11. qDebug() << "jd.toJson(QJsonDocument::Indented)";
    12. qDebug() << jd.toJson(QJsonDocument::Indented);
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default 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.

  3. #3
    Join Date
    Aug 2013
    Posts
    2
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default 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.

Similar Threads

  1. Replies: 7
    Last Post: 24th September 2012, 07:17
  2. Compact View
    By wirasto in forum Qt Programming
    Replies: 7
    Last Post: 17th July 2010, 14:39
  3. MVC example not working
    By yyiu002 in forum Newbie
    Replies: 1
    Last Post: 30th June 2010, 00:07
  4. My first app not working
    By Noks in forum Newbie
    Replies: 6
    Last Post: 2nd February 2010, 16:34
  5. Mac OS X UI not working
    By hvengel in forum Qt Programming
    Replies: 3
    Last Post: 1st April 2006, 01:02

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.