How to store json data in std::vector<unsigned char> ?
Solved
C++ Gurus
-
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;
-
@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());
-
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?
-
@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());
-
@Christian-Ehrlicher can you suggest me book for c++. because i have intermediate knowledge. i know most of c++ except advance level concept.