How to give JSON Object to QTScript
Unsolved
General and Desktop
-
Hi all,
I'm trying to set a variable in QTScript from a JSON Object. I explain my problem :
I make CURL request to an external API RESTFULL. The API REST returns JSON Object or JSON Array. The CURL request works well. I get the right JSON result
When the request is done, I need to give this result (Object or array) to a script in QTScript.
My actual code is the following one :MyCurlConnexion curl ; // make cURL request QJsonObject jobj = curl.requestGet("https://localhost:8082/api/....................."); // request have been hidden for the forum // set QScriptValue array = engine->newArray(jobj.count()); QStringList keylist = jobj.keys(); for (int i=0; i<jobj.count(); i++) { array.setProperty(keylist.at(i),jobj.value(keylist.at(i))); } engine->globalObject().setProperty(QString("SqlResult"),array);
This code is not fully tested, just to show the principal of the actual system.
But if the JSON result is not a unique object, but an JSON array of JSON object, my code is not working.
My Question : How can I send a "generic" JSON result to my QTScript ?
is there a solution like this :engine->globalObject().setProperty(QString("SqlResult"),myjsonobject);
or another way to solve my problem.
Thanks for your help. BRs