Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QJsonObject creation error



  • I have QString containing the JSON I want to convert to a JSON object:

    QString strJSON("{'db':'test','host':'localhost','usr':'root','pass':'password'};");
    

    I then try to create an instance of QJsonObject:

    QJsonObject objJSON = QJsonDocument::fromJson(strJSON.toLatin1(), &objJsonErr).object();
    

    This fails and objJsonErr contains:

    error    QJsonParseError::UnterminatedObject (1)
    offset  2
    

    As far as I can see the JSON is perfectly valid.



  • The problem was the use of ' instead of ", also the trailing ; had to be removed.



  • The problem was the use of ' instead of ", also the trailing ; had to be removed.


Log in to reply