Results 1 to 5 of 5

Thread: reading JSON file in Qt5

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: reading JSON file in Qt5

    Does /tmp/settings.json exists? Is it well formed? Also try QJsonDocument::fromJson and see what error (QJsonParseError) you get.

    EDIT: Forget the first questions....

    EDIT 2:
    Qt Code:
    1. QString str = "{"
    2. " \"Herausgeber\": \"Xema\","
    3. " \"Nummer\": \"1234-5678-9012-3456\","
    4. " \"Deckung\": 2e+6,"
    5. " \"Währung\": \"EURO\","
    6. " \"Inhaber\": {"
    7. " \"Name\": \"Mustermann\","
    8. " \"Vorname\": \"Max\","
    9. " \"männlich\": true,"
    10. " \"Hobbys\": [ \"Reiten\", \"Golfen\", \"Lesen\" ],"
    11. " \"Alter\": 42,"
    12. " \"Kinder\": [],"
    13. " \"Partner\": null"
    14. " }"
    15. "}";
    16. QJsonDocument d = QJsonDocument::fromJson(str.toUtf8());
    17. qWarning() << d.isNull();
    To copy to clipboard, switch view to plain text mode 
    See if that works for you and then replace str.toUtf8() through your readAll().
    Last edited by Lykurg; 18th January 2013 at 08:51.

Similar Threads

  1. Using external Json file in QML
    By Kelteseth in forum Qt Quick
    Replies: 0
    Last Post: 30th November 2012, 18:08
  2. Reading XML file into a data file correctly?
    By falconium in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2011, 19:55
  3. Reading XML file using DOM
    By rk0747 in forum Qt Programming
    Replies: 6
    Last Post: 4th February 2010, 23:09
  4. help in reading XML file
    By cshiva_in in forum Qt Programming
    Replies: 1
    Last Post: 24th March 2008, 14:55
  5. reading from a file
    By mickey in forum General Programming
    Replies: 32
    Last Post: 19th July 2007, 02:04

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.