Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. How to store json data in std::vector<unsigned char> ?

How to store json data in std::vector<unsigned char> ?

Scheduled Pinned Locked Moved Solved C++ Gurus
4 Posts 2 Posters 887 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on 22 Apr 2022, 10:52 last edited by Qt embedded developer
    #1

    i have seen some code where i retrieve data of json using below code:

                    std::vector<unsigned char> VectorResponseData;
    		VectorResponseData = txnContext->getPrivateData();
    		std::string StrReSponseData(VectorResponseData.begin(),VectorResponseData.end());
    
    		JSObject JSONResponseData;
    		JSONResponseData.load(StrReSponseData);
    		std::string strCardUID = "";
    
    		strCardUID = JSONResponseData("AID").getString();
    		txnContainer->setstrCardUID(strCardUID);
    		LOGF_ERROR("AnalyzePaymentResponse::strCardUID:  %s",strCardUID.c_str());
    

    So i want example that show how we can store json data in below vector ? if possible give the example.

    std::vector<unsigned char> VectorResponseData;

    1 Reply Last reply
    0
    • C Christian Ehrlicher
      22 Apr 2022, 10:56

      And where's the relation to Qt here? Please go, take a book and learn basic c++.

      What exactly do you want to store in your vector? Which variable from your code above?

      Q Offline
      Q Offline
      Qt embedded developer
      wrote on 22 Apr 2022, 10:59 last edited by
      #3

      @Christian-Ehrlicher I got the answer :

      actually i want to do something like below:

                              JSObject CardTopUpInfo;
      			CardTopUpInfo("Topup_Mode") = pTransactionData->getSelectedTopUpMenuID();
      			//CardTopUpInfo("Topup_Amount") = pTransactionData->getEnteredTopUpAmount();
      			std::string tempStr = CardTopUpInfo.dump().c_str();
      			DBGF_TRACE("AFCS::PrivateData: %s",tempStr);
      			std::vector<unsigned char> vectr(tempStr.begin(),tempStr.end());
      
      1 Reply Last reply
      0
      • C Offline
        C Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 22 Apr 2022, 10:56 last edited by
        #2

        And where's the relation to Qt here? Please go, take a book and learn basic c++.

        What exactly do you want to store in your vector? Which variable from your code above?

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        Q 2 Replies Last reply 22 Apr 2022, 10:59
        0
        • C Christian Ehrlicher
          22 Apr 2022, 10:56

          And where's the relation to Qt here? Please go, take a book and learn basic c++.

          What exactly do you want to store in your vector? Which variable from your code above?

          Q Offline
          Q Offline
          Qt embedded developer
          wrote on 22 Apr 2022, 10:59 last edited by
          #3

          @Christian-Ehrlicher I got the answer :

          actually i want to do something like below:

                                  JSObject CardTopUpInfo;
          			CardTopUpInfo("Topup_Mode") = pTransactionData->getSelectedTopUpMenuID();
          			//CardTopUpInfo("Topup_Amount") = pTransactionData->getEnteredTopUpAmount();
          			std::string tempStr = CardTopUpInfo.dump().c_str();
          			DBGF_TRACE("AFCS::PrivateData: %s",tempStr);
          			std::vector<unsigned char> vectr(tempStr.begin(),tempStr.end());
          
          1 Reply Last reply
          0
          • C Christian Ehrlicher
            22 Apr 2022, 10:56

            And where's the relation to Qt here? Please go, take a book and learn basic c++.

            What exactly do you want to store in your vector? Which variable from your code above?

            Q Offline
            Q Offline
            Qt embedded developer
            wrote on 29 Apr 2022, 05:52 last edited by
            #4

            @Christian-Ehrlicher can you suggest me book for c++. because i have intermediate knowledge. i know most of c++ except advance level concept.

            1 Reply Last reply
            0

            1/4

            22 Apr 2022, 10:52

            • Login

            • Login or register to search.
            1 out of 4
            • First post
              1/4
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved