Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. JSON.parse reports error, even despite proper parsing
Forum Updated to NodeBB v4.3 + New Features

JSON.parse reports error, even despite proper parsing

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 999 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qttester5
    wrote on last edited by
    #1

    I have a very simple, short JSON piece that validates fine with online validators. When I use JSON.parse in my QML, it parses correctly and I am able to use the values just fine. However, the console logs:

    @JSON.parse: Parse error@

    Why would Qt Quick (5.2) indicate erroneous parsing when the parsing is in fact happening, and the JSON is valid anyway?

    The JSON is simply this:

    @{
    "files": ["gun","tree","1"],
    "repeat": true,
    "fps": 25
    }@

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qttester5
      wrote on last edited by
      #2

      Turns out this was because I was using an XMLHttpRequest for the parse data, and should have checked that the XMLHttpRequest was in a finished state before attempting to parse; eventually, it would parse correctly, but intermediate states would cause the parsing to occur on incomplete data.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved