Results 1 to 4 of 4

Thread: converting list to JSON - performance issue.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2016
    Posts
    53
    Thanks
    13
    Qt products
    Qt4 Qt5
    Platforms
    Windows Android

    Default converting list to JSON - performance issue.

    Hi,

    I want to pass the PortalSearchItems list to be passed from qml to Cpp. Eventhough, I can get the result, app got just killed, when this code executes. I assume performance issue.

    Code Snippet: main.qml
    --------------------------------------
    Qt Code:
    1. var varidPortalSearchItemsCount = idPortalSearchItems.totalResults;
    2.  
    3. var vartextJson = "";
    4.  
    5. for (var ii = 0; ii <= varidPortalSearchItemsCount -1 ;ii++)
    6. {
    7. vartextJson += '{"title":"'+ idPortalSearchItems.results[ii].title +'"
    8. ,"owner":"'+ idPortalSearchItems.results[ii].owner +'"
    9. ,"url":"'+ idPortalSearchItems.results[ii].url +'"
    10. ,"itemId":"'+ idPortalSearchItems.results[ii].itemId +'"
    11. }' + ',';
    12. }
    13.  
    14.  
    15. vartextJson = vartextJson.substring(0, vartextJson.length-1) + ']';
    16. vartextJson = '[' + vartextJson;
    17. var varJsonString =JSON.parse(vartextJson);
    18. objHomeController.eveWriteXML(varJsonString);
    To copy to clipboard, switch view to plain text mode 

    HomeController.h
    --------------------------
    Qt Code:
    1. Q_INVOKABLE bool eveWriteXML(const QJsonObject &pqvarPortalItemResult);
    To copy to clipboard, switch view to plain text mode 

    HomeController.cpp
    --------------------------
    Qt Code:
    1. bool HomeController::eveWriteXML(const QJsonObject &pqvarPortalItemResult)
    2. {
    3.  
    4. QVariantMap jsonQVariantMap = pqvarPortalItemResult.toVariantMap();
    5.  
    6.  
    7.  
    8. for(QVariantMap::const_iterator iter = jsonQVariantMap.begin(); iter != jsonQVariantMap.end(); ++iter) {
    9.  
    10. QVariant objQVariant = iter.key();
    11. QVariant objQVariant1 = iter.value();
    12.  
    13. QString strTitleValue = objQVariant1.toMap().values("title").value(0).toString();
    14. QString strUrlValue = objQVariant1.toMap().values("url").value(0).toString();
    15. QString strOwnerValue = objQVariant1.toMap().values("owner").value(0).toString();
    16. QString strItemIdValue = objQVariant1.toMap().values("itemId").value(0).toString();
    17.  
    18. }
    To copy to clipboard, switch view to plain text mode 
    Thanks In advance.
    Last edited by anda_skoa; 29th September 2016 at 10:02. Reason: missing [code] tags

Similar Threads

  1. Parsing a JSon webservice reply issue
    By roseicollis in forum Qt Programming
    Replies: 12
    Last Post: 11th February 2015, 08:42
  2. Replies: 0
    Last Post: 30th September 2013, 19:47
  3. Performance issue
    By Skorpien126 in forum Qt Programming
    Replies: 4
    Last Post: 2nd July 2010, 16:02
  4. Replies: 0
    Last Post: 16th May 2010, 17:53
  5. Performance Issue
    By linuxdev in forum Qt Programming
    Replies: 1
    Last Post: 10th December 2008, 15:00

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.