Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Tags
    3. json
    Log in to post

    • SOLVED Read from Json in an order
      General and Desktop • qt5 json jsonparser • • suslucoder  

      9
      0
      Votes
      9
      Posts
      39
      Views

      @jsulm thank you. I did it with your solution. It works fine.
    • SOLVED How to parse such a complex json file
      General and Desktop • qt5 json read • • suslucoder  

      10
      0
      Votes
      10
      Posts
      75
      Views

      @suslucoder The "Plan" array is a little unusual because the objects it contains are not all of the same structure. Usually, arrays should contain a sequence of elements of the same type. However, it is legal JSON. If you are certain that the first element of the "Plan" array will have the structure as in your example above, you can perhaps rely on the others to all have the 2nd type structure. Otherwise, you might need to check for the existence of certain keys -- for example, by using the function QJsonObject::contains() to determine which kind of object it is.
    • UNSOLVED Creating json file with subroot
      General and Desktop • qt5 json root • • suslucoder  

      13
      0
      Votes
      13
      Posts
      29
      Views

      @KroMignon thank you
    • SOLVED no member named 'write' in 'QString'
      General and Desktop • qt5 json write • • suslucoder  

      9
      0
      Votes
      9
      Posts
      42
      Views

      @suslucoder said in no member named 'write' in 'QString': Im on ubuntu :) Oh, OK, then it doesn't actually matter as there is no "text vs binary" mode/format under Linux! Nonetheless I think it's good practice to put QIODevice::Text in, just in case you ever port to Windows...
    • UNSOLVED Storing real time datas as a JSON File
      General and Desktop • qt5 json real time • • suslucoder  

      6
      0
      Votes
      6
      Posts
      29
      Views

      @suslucoder This is contrary to 'real-time'.
    • SOLVED Creating a JSON file
      General and Desktop • qt5 json write • • suslucoder  

      7
      0
      Votes
      7
      Posts
      42
      Views

      @KroMignon thank you
    • UNSOLVED Error when reading Json File
      General and Desktop • qt5 json jsonparser • • suslucoder  

      10
      -1
      Votes
      10
      Posts
      74
      Views

      @Christian-Ehrlicher I did use it. It looks in a code tag in my screen.
    • UNSOLVED How can I create our configuration file?
      General and Desktop • qt5 json config file • • suslucoder  

      19
      0
      Votes
      19
      Posts
      44
      Views

      @jsulm Ok. Thank you for your answers.
    • UNSOLVED Create QByteArray JSON with special characters (é, ...) as unicode (\uxxxx)
      General and Desktop • json json parser encoding unicode • • Mixlu  

      4
      0
      Votes
      4
      Posts
      44
      Views

      @Mixlu What do you mean by "Unicode escaped format"? Normal characters won't be escaped, even a character like é also doesn't need to be escaped. If you use some special characters like \0, then it will be escaped to\u0000
    • UNSOLVED Consistency between null QJsonValue and QVariant
      General and Desktop • json qvariant • • Moia  

      5
      0
      Votes
      5
      Posts
      63
      Views

      Maybe @Moia want a method to get that QVariant without a QJsonValue? By looking into the source code of QJsonValue, you can see that value comes from QVariant::fromValue(nullptr)
    • UNSOLVED sending Json to local Ip
      QML and Qt Quick • json https post local ip • • Mahdi  

      2
      0
      Votes
      2
      Posts
      57
      Views

      Hi, From the looks of it, you are looking for the XMLHttpRequest example.
    • UNSOLVED extract values from json result
      General and Desktop • json json parser • • Qjay  

      5
      0
      Votes
      5
      Posts
      161
      Views

      well this is how i have done it. Not sure if this is even the right way ( looks like a mess to me) QJsonDocument doc = QJsonDocument::fromJson(result.toUtf8()); qDebug() << "doc :" << doc; QJsonObject doc_obj = doc.object(); qDebug() << "doc_obj :" << doc_obj; QJsonArray doc_array = doc_obj.value("results").toArray(); doc_obj = doc_array[0].toObject(); doc_array = doc_obj.value("series").toArray(); doc_obj = doc_array[0].toObject(); doc_array = doc_obj.value("values").toArray(); for(int i = 0; i < doc_array.size(); i++) { QJsonArray arr = doc_array[i].toArray(); qDebug() << "doc value : " << arr[1].toString(); } i am getting resuls though
    • UNSOLVED How I can create Json Format in Qt ?
      General and Desktop • json qjsondocument • • npatil15  

      7
      0
      Votes
      7
      Posts
      417
      Views

      @mrjj said in How I can create Json Format in Qt ?: someObj Thanks, it helps a lot.
    • SOLVED Strange Json issue, conversion from QByteArray to QJsonDocument not working as intended
      General and Desktop • qtcreator json installation bytearray • • DanBar  

      16
      0
      Votes
      16
      Posts
      2880
      Views

      @jsulm we make an installation file for our combined system, including multiple programs sharing some but not other resources. we use an nsi script to manage this. usually works fine. I just missed updating some of the .dll files.
    • SOLVED Change a QJsonObject into an integer
      General and Desktop • gui json change qjsonobject integers • • hoonara  

      10
      0
      Votes
      10
      Posts
      2514
      Views

      @Christian-Ehrlicher ahh, you are right. Good catch. http://doc.qt.io/qt-5/qjsonvalue.html#toDouble converts the QJsonValue to double if its that type(). in this case it will return defaultValue (0) so its something like QJsonValue bid1 = jsonObj.value("bid_1"); QString asStr=bid1.toString(); double n = asStr.toDouble(); qDebug() << n;
    • SOLVED How to get a Json value from an api and display it in a GUI
      General and Desktop • c++ json qnetworkrequest qurl api • • hoonara  

      8
      0
      Votes
      8
      Posts
      1671
      Views

      @Lodhi-bhkr Sorry, but this is not a question. What did you try? What problems do you have? Please ask more specific questions. Looks like you asked here already: https://forum.qt.io/topic/120439/qt-code-to-send-data-on-postman-http-post-request
    • UNSOLVED How should i store the results ??
      General and Desktop • qtcreator qt5 json qbytearray json parser • • Qjay  

      6
      0
      Votes
      6
      Posts
      797
      Views

      @Paul-Colby Thanks i myself did something like this :) QVariantMap json_map; const QJsonDocument doc = QJsonDocument::fromJson(output); qDebug().noquote() << doc; qDebug().noquote() << doc.array(); foreach (auto value, doc.array()) { qDebug().noquote() << value; qDebug().noquote() << value.toObject(); qDebug().noquote() << value.toObject().value("name"); json_map["name"] = value.toObject().value("name").toString(); json_map["installed"] = value.toObject().value("installed").toBool(); json_map["id"] = value.toObject().value("id").toString(); json_map["filename"] = value.toObject().value("filename").toString(); }
    • UNSOLVED How to create a web service and send Json to this?
      General and Desktop • sqlite json http web service web server • • Saman19  

      2
      0
      Votes
      2
      Posts
      363
      Views

      @Saman19 You may want to check out Cutelyst if you want to support the HTTP protocol. If you do not need to rely on HTTP, but just want to receive JSON (or any custom protocol), take a look at QTcpServer examples.
    • SOLVED Key type of QJsonObject
      General and Desktop • json json parser qjsonobject • • tansgumus  

      5
      0
      Votes
      5
      Posts
      3467
      Views

      Thank you guys. What a wonderful quick responses.
    • UNSOLVED JSON with multi tasking
      Mobile and Embedded • json websocket java embedded qt qt c++ • • A Former User  

      8
      0
      Votes
      8
      Posts
      1606
      Views

      Hi @Geeva, @Geeva said in JSON with multi tasking: @JKSH Thanks for solving basic confusion. I have one more doubt also. Here, I have attached program for verification. I hope you can provide a proper solution You're welcome. I'm happy to teach you basics. However, verifying your program is too difficult to do on a forum. You need to do 2 things: Take C++ lessons Practice writing and debugging simple programs for your hardware
    • UNSOLVED QJsonValue decimal number
      General and Desktop • json qjsonvalue qdecimal • • debegr  

      8
      0
      Votes
      8
      Posts
      2915
      Views

      Hi @SGaist , no sorry. This was my first try to solve this. It dosn't work because of: @JNBarchan said: Once JSON has taken it as a double, it's too late. With a small test program I testes Qt-JSON: https://github.com/qt-json/qt-json #include <QCoreApplication> #include <QDebug> #include "json.h" int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QString json = "{\"success\":true,\"message\":\"some-message\",\"number1\":1.234,\"number2\":\"5.678\"}"; bool ok; QtJson::JsonObject result = QtJson::parse(json, ok).toMap(); qDebug() << "number1: " << result["number1"].toString(); qDebug() << "number2: " << result["number2"].toString(); return a.exec(); } Which gives me the following output: number1: "1.234" number2: "5.678" So I think I can work with this library, but a bit sad about the truth, that such a case can't be handled without external libraries.
    • SOLVED Parsing JSON in QML
      QML and Qt Quick • json json parser parsing • • Stefan Monov76  

      3
      0
      Votes
      3
      Posts
      1832
      Views

      @Wieland: Thanks!
    • UNSOLVED Storing a JSON object
      QML and Qt Quick • json • • Sikarjan  

      11
      0
      Votes
      11
      Posts
      4122
      Views

      Thanks again for the explanation. I wish I had more time to learn programming correctly...
    • UNSOLVED Parsing JSON with QML
      QML and Qt Quick • json • • Sikarjan  

      3
      0
      Votes
      3
      Posts
      3064
      Views

      Hi, I am using the one dridk mentioned. The parsing works fine and I use listModel.append({jsonObject}); to fill my ListView. Everything is in the ListModel besides z. If I do: for(var i in jsonObject){ eventModel.append(jsonObject[i]) eventModel.set(i, {"zn":jsonObject[i]["z"][0]}) } z is added as an array. Just like in the JSON object just without the []-brackets.
    • UNSOLVED How to I prepare models for Canvas3D view?
      QML and Qt Quick • json 3d canvas mesh • • Aras  

      2
      0
      Votes
      2
      Posts
      783
      Views

      Try to triangulate faces of your mesh (select your shape, switch to Edit Mode and press Ctrl+T ).
    • SOLVED can't get JSON file from QNetworkReply
      General and Desktop • qnetworkaccessm json qwebengineview qnetworkrequest qnetreply • • nazimGT  

      2
      0
      Votes
      2
      Posts
      3565
      Views

      resolved !! i've chenged m_pNetworkAccessManager->get(request); by request.setRawHeader("Content-Type", "application/x-www-form-urlencoded"); QByteArray par=""; m_pNetworkAccessManager->post(request,par);
    • Process returned JSON in webview
      General and Desktop • qml qt quick webview json • • Qjay  

      4
      0
      Votes
      4
      Posts
      1537
      Views

      In answer to my original question i did something like this onUrlChanged: { console.log(searchwebview.url); test_json(); } and i made this function to parse the returned JSON ( this function is not perfect yet ) function test_json() { var p_url = searchwebview.url var http = new XMLHttpRequest(); var json , parse , text , rev_id; http.onreadystatechange = function(){ if(http.readyState == 4 && http.status == 200) { json = http.responseText; parse = JSON.parse(json); rev_id = parse.parse.revid; console.log(rev_id); text = parse.parse.text["*"]; //console.log(text); // <-- STRIP ME (o.O) while(text.match(/&#39;\/index.php/)){ text = text.replace(/&#39;\/index.php/, "http://en.wikitolearn.org/index.php"); text = text.replace(/&amp;/,"&"); text = text.replace(/MathShowImage&amp;/, "MathShowImage&") text = text.replace(/mode=mathml&#39;/, "mode=mathml\""); text = text.replace(/<meta class="mwe-math-fallback-image-inline" aria-hidden="true" style="background-image: url\(/ ,"<img style=\"background-repeat: no-repeat; background-size: 100% 100%; vertical-align: -0.838ex;height: 2.843ex; \" src=\""); text = text.replace(/<meta class="mwe-math-fallback-image-display" aria-hidden="true" style="background-image: url\(/ ,"<img style=\"background-repeat: no-repeat; background-size: 100% 100%; vertical-align: -0.838ex;height: 2.843ex; \" src=\""); text = text.replace(/&amp;mode=mathml\"/ , "&mode=mathml>\""); text = styling + text; } console.log(text); // after strip :p . webview.loadHtml(text); } }; http.open('GET',p_url); http.send(); }
    • SOLVED How to access this JSON ( indented JSON )
      General and Desktop • json • • Qjay  

      9
      0
      Votes
      9
      Posts
      2253
      Views

      Crap i mixed 2 codes. Sorry for that :m. Thank you everyone
    • SOLVED how to get indented JSON values in C++ ?
      General and Desktop • c++ json qt application json parser • • Qjay  

      12
      0
      Votes
      12
      Posts
      3451
      Views

      @Gojir4 Sure, Thanks for your Help.
    • SOLVED Creating JSON files from scratch
      General and Desktop • json create • • marlenet15  

      11
      0
      Votes
      11
      Posts
      4393
      Views

      @Paul-Colby YES!! I can't believe I didn't see it. I guess I didn't read it carefully. Thank you!!!!
    • SOLVED Create Json using QJsonDocument
      General and Desktop • json qjsondocument • • 4j1th  

      3
      0
      Votes
      3
      Posts
      22913
      Views

      @Paul-Colby Thank you
    • UNSOLVED QxOrm 1.4.2 & QxEntityEditor 1.1.9 released : support JSON serialization
      Announcements • database json serialization orm • • qxorm  

      1
      0
      Votes
      1
      Posts
      617
      Views

      No one has replied

    • [SOLVED]parse Json in Qt5
      General and Desktop • json json parser • • 4j1th  

      7
      0
      Votes
      7
      Posts
      21359
      Views

      @yeckel Thank you very much it's working now json file [{"name":"ugiuiug","dob":"0000-00-00"},{"name":"jghighui","dob":"0000-00-00"},{"name":"igiyug","dob":"0000-00-00"},{"name":"jhu","dob":"0000-00-00"}] Qt code QFile file; file.setFileName("test1.json"); file.open(QIODevice::ReadOnly | QIODevice::Text); QJsonParseError jsonError; QJsonDocument flowerJson = QJsonDocument::fromJson(file.readAll(),&jsonError); if (jsonError.error != QJsonParseError::NoError){ qDebug() << jsonError.errorString(); } QList<QVariant> list = flowerJson.toVariant().toList(); QMap<QString, QVariant> map = list[0].toMap(); qDebug() << map["name"].toString();
    • Unicode/UTF-8 encoding while getting data from site via QWebElement
      Qt WebKit • json webkit json parser utf-8 webview webkit encoding unicode qwebframe qwebelement webelementcolle • • slesher  

      1
      0
      Votes
      1
      Posts
      833
      Views

      No one has replied

    • Multiples Connections in QML
      QML and Qt Quick • qml c++ qtquick qnetworkaccessm json qnetworkreply connections • • Antonio Ortiz  

      2
      0
      Votes
      2
      Posts
      2205
      Views

      Not quite understand your question.. Generally speaking, Javascript application use a Promise object for deferred and asynchronous operation. For example , do something when two or more asynchronous operations completed (in any order). Qt do not bundle any Promise implementation by default. You could get a one from my github repo: benlau/quickpromise Example Promise { resolveWhen: Q.all([endpoint1. onReplyStatusChanged,endpoint2. onReplyStatusChanged]); onFulfilled: { // It will be triggered only if both of the endpoint emitted the signal controller.setData1(); controller.setData2(); } }
    • [SOLVED]QByteArray to PNG image
      General and Desktop • qimage json serialization qbyt • • GGAllin  

      7
      0
      Votes
      7
      Posts
      6148
      Views

      @SGaist Hi SGaist, i solved manupulating my BA manually int bW = bitmap.value("width").toInt(); int bH = bitmap.value("height").toInt(); QString shortFileName = bitmap.value("id").toString(); QString fileName = btb::ResourceManager().getClipDir().absolutePath().append("/"+shortFileName+".png"); QByteArray ba = bitmap.value("rect").toByteArray(); QByteArray to = QByteArray(); for(int i=0; i<bWbH;i++) { // ARGB -> ABGR to.append( ba[i4+3]); to.append( ba[i4+2]); to.append( ba[i4+1]); to.append( ba[i4]); } QImage image((const unsigned char)to.data(),bW,bH,QImage::Format_RGB32); //image.invertPixels(); image.save(fileName,"PNG"); thanks for help!
    • Unknown Android deployment JSON file location
      Mobile and Embedded • android error json • • Alfakyn  

      6
      0
      Votes
      6
      Posts
      2926
      Views

      Thanks for the tip, I'll try it :).
    • Why the SLOT method not triggered? [solved]
      QML and Qt Quick • qobject json json parser • • Lapson  

      3
      0
      Votes
      3
      Posts
      1727
      Views

      I finally found a method to solve the problem. The following is the code snippet. main.cpp #include <QGuiApplication> #include <QStringList> #include <qqmlengine.h> #include <qqmlcontext.h> #include <qqml.h> #include <QtQuick/qquickitem.h> #include <QtQuick/qquickview.h> #include <jsondata.h> int main(int argc, char ** argv) { QGuiApplication app(argc, argv); QStringList datalist; Jsondata jsondata; jsondata.datalistmethod(); datalist = jsondata.datalist; QQuickView view; QQmlContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", QVariant::fromValue(datalist)); view.setSource(QUrl("qrc:main.qml")); view.show(); return app.exec(); } jsondata.h #ifndef JSONDATA_H #define JSONDATA_H #include <QObject> #include <QNetworkReply> #include <QStringList> #include <QNetworkAccessManager> class Jsondata : public QObject { Q_OBJECT public: QStringList datalist; explicit Jsondata(QObject *parent =0); void datalistmethod(); public slots: void onResult (QNetworkReply*); private: QNetworkAccessManager *manager; }; jsondata.cpp #include "jsondata.h" #include <QNetworkReply> #include <QNetworkRequest> #include <QNetworkAccessManager> #include <QJsonDocument> #include <QJsonObject> #include <QJsonArray> #include <QEventLoop> #include <QtQuick/qquickitem.h> #include <QtQuick/qquickview.h> #include <QTimer> #include <qqmlengine.h> #include <qqmlcontext.h> #include <qqml.h> Jsondata::Jsondata(QObject *parent) : QObject(parent) { } void Jsondata::datalistmethod() { // Now parse this JSON according to your needs ! manager = new QNetworkAccessManager(this); manager->setNetworkAccessible(QNetworkAccessManager::Accessible); QNetworkRequest request; QEventLoop eventloop; QUrl url("http://***/api/web/v1/links"); request.setUrl(url); QNetworkReply *reply = manager->get(request); connect(reply, SIGNAL(finished()), &eventloop, SLOT(quit())); eventloop.exec(); onResult(reply); } void Jsondata::onResult(QNetworkReply* reply) { QString data = (QString) reply->readAll(); qDebug() << "Response:" << data; QJsonDocument jsonResponse = QJsonDocument::fromJson(data.toUtf8()); QJsonArray jsonArray = jsonResponse.array(); foreach (const QJsonValue & value, jsonArray) { QJsonObject obj = value.toObject(); datalist.append(obj["name"].toString()); datalist.append(obj["link"].toString()); } } By adding event loop, the datalist method will wait for the onResult method completed to execute next line of code. This is using the example of string list model. If anyone feel it useful for reference, please +1 my post. Thank you. ^^