Parsing JSON



  • Does anyone know how I can just get the value "test_value"

    Input is
    {"a":"test_value"}

    The actual value that is outputted is
    QJsonValue(string, "test_value")

    I would like it to be just
    test_value

        QString val;
        val = finished->readAll();
    
        QJsonDocument doc = QJsonDocument::fromJson(val.toUtf8());
        QJsonObject jobj = doc.object();
        qDebug() << jobj.value(QString("a"));


  • Change:

    qDebug() << jobj.value(QString("a"));

    to

    qDebug() << jobj["a"].toString();


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.