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 Updated to NodeBB v4.3 + New Features

QJson parsing without quotation marks

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 500 Views 2 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.
  • metaDomM Offline
    metaDomM Offline
    metaDom
    wrote on 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 last edited by
      #2

      Hi,

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

      will work as you provided a number 5678.

      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