I'm using QScriptEngine to create JSON object like this.

Qt Code:
  1. QStringList aApplicatoinIds;
  2. QStringList aDisplaynames;
  3. QStringList aIconPaths;
  4. QList<int> aMessageCounts;
  5. aApplicatoinIds.append("app.test.com");
  6. aDisplaynames.append("testi appi");
  7. aIconPaths.append("c:\\data\\icon2.bmp");
  8. aMessageCounts.append(2);
  9. aApplicatoinIds.append("app.demo.com");
  10. aDisplaynames.append("demo appi");
  11. aIconPaths.append("c:\\data\\demo.bmp");
  12. aMessageCounts.append(4);
  13. int size = aApplicatoinIds.count();
  14.  
  15.  
  16. QScriptEngine engine;
  17. QScriptValue list = engine.newArray(size);
  18.  
  19. for (int i=0; i < size; i++)
  20. {
  21. QScriptValue application = engine.newObject();
  22. application.setProperty(JSON_APPLICATIONID,aApplicatoinIds.at(0));
  23. application.setProperty(JSON_DISPLAYNAME,aDisplaynames.at(0));
  24. application.setProperty(JSON_ICONPATH,aIconPaths.at(0));
  25. application.setProperty(JSON_MESSAGES,aMessageCounts.at(0));
  26. list.setProperty(i,application);
  27. LOGTXT("++");
  28. }
  29.  
  30. QScriptValue notify = engine.newObject();
  31. notify.setProperty(JSON_LIST,list);
  32.  
  33. QScriptValue globalObj = engine.newObject();
  34. globalObj.setProperty(JSON_NOTIFY,notify);
  35.  
  36. engine.setGlobalObject(globalObj);
To copy to clipboard, switch view to plain text mode 

Now, I'¨m trying to get engine output as JSON in QString like this:

Qt Code:
  1. {
  2. "notify":{
  3. "list": [
  4. {
  5. "applicationid":"test.app.com",
  6. "displayname":"testing",
  7. "iconpath":"c:\data\test.img",
  8. "messages":5
  9. }
  10. ]}
  11. }
To copy to clipboard, switch view to plain text mode 

How to do it?

Or if you can show some code example how to create JSON string, I'm listening.