Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QJson parsing without quotation marks
Forum Update on Monday, May 27th 2025

QJson parsing without quotation marks

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 486 Views
  • 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.
  • M Offline
    M Offline
    metaDom
    wrote on 1 Sept 2015, 12:40 last edited by
    #1

    Example QByteArray (ba) looks like:

    {
    "testA": "1234",
    "testB": 5678,
    }

    Parsing code:

    QJsonDocument jsonResponse = QJsonDocument::fromJson(ba);
    QJsonObject tokenObj = jsonResponse.object();
    testA= tokenObj["testA"].toString();
    testB = tokenObj["testB"].toString();

    testA properly returns "1234" while testB returns ""

    Any ideas are welcome, thanks in advance!

    1 Reply Last reply
    0
    • C Offline
      C Offline
      clochydd
      wrote on 1 Sept 2015, 12:44 last edited by
      #2

      Hi,

      testB = tokenObj["testB"].toInt();
      

      will work as you provided a number 5678.

      1 Reply Last reply
      0

      1/2

      1 Sept 2015, 12:40

      • Login

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