Click here to Skip to main content
15,890,557 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: foreach - basic C++ question Pin
Maximilien29-Aug-22 8:23
Maximilien29-Aug-22 8:23 
AnswerRe: foreach - basic C++ question Pin
CPallini29-Aug-22 20:05
mveCPallini29-Aug-22 20:05 
GeneralMessage Closed Pin
30-Aug-22 3:11
Member 1496877130-Aug-22 3:11 
GeneralRe: foreach - basic C++ question Pin
CPallini30-Aug-22 3:16
mveCPallini30-Aug-22 3:16 
AnswerRe: foreach - basic C++ question Pin
Richard MacCutchan29-Aug-22 21:56
mveRichard MacCutchan29-Aug-22 21:56 
Questionlinker error lnk2005 Pin
Roberto64_Ge29-Aug-22 4:19
Roberto64_Ge29-Aug-22 4:19 
AnswerRe: linker error lnk2005 Pin
k505429-Aug-22 4:35
mvek505429-Aug-22 4:35 
GeneralRe: linker error lnk2005 Pin
Roberto64_Ge29-Aug-22 5:03
Roberto64_Ge29-Aug-22 5:03 
GeneralRe: linker error lnk2005 Pin
k505429-Aug-22 5:09
mvek505429-Aug-22 5:09 
GeneralRe: linker error lnk2005 Pin
Roberto64_Ge29-Aug-22 5:13
Roberto64_Ge29-Aug-22 5:13 
GeneralRe: linker error lnk2005 Pin
k505429-Aug-22 5:28
mvek505429-Aug-22 5:28 
GeneralRe: linker error lnk2005 Pin
Roberto64_Ge29-Aug-22 8:56
Roberto64_Ge29-Aug-22 8:56 
AnswerRe: linker error lnk2005 Pin
Richard MacCutchan29-Aug-22 4:45
mveRichard MacCutchan29-Aug-22 4:45 
GeneralRe: linker error lnk2005 Pin
Roberto64_Ge29-Aug-22 5:14
Roberto64_Ge29-Aug-22 5:14 
Questiontracking down linker errors Pin
Calin Negru27-Aug-22 3:50
Calin Negru27-Aug-22 3:50 
AnswerRe: tracking down linker errors Pin
Mircea Neacsu27-Aug-22 4:03
Mircea Neacsu27-Aug-22 4:03 
SuggestionRe: tracking down linker errors Pin
Richard MacCutchan27-Aug-22 6:44
mveRichard MacCutchan27-Aug-22 6:44 
General[solved]Re: tracking down linker errors Pin
Calin Negru27-Aug-22 8:01
Calin Negru27-Aug-22 8:01 
QuestionUsing nlohmann JSON to insert more data Pin
Kiran Satish26-Aug-22 7:03
Kiran Satish26-Aug-22 7:03 
I have a json file genrated in python from another system that needs to be read/updated in another MFC application. I can successfully read the existing data from the json file using nlohmann json add-in. For example, the file consists of two data fields with one field having any array of two subfields as below

C++
{
  "city_data":[
     {
       "t":"m",
       "l":[12.0,10.3,0.0,1.0]
     },
     {
       "t":"l",
       "l":[10.1,20.37,0.0,1.0]
     },
     {
       "t":"l",
       "l":[47.82,4.63,0.0,1.0]
     },
     {
       "t":"m",
       "l":[67.66,43.33,0.0,1.0]
     }
   ],
   "map_data":"JZDKZTCaTyWQymUwmk8lkMplMJpPJZDKZTCaTyWQymUwmk/8/+n8AVAZ1WCxk8rYAAAAASUVORK5CYII="
}

The "map_data" is basically base64 encoded png image.
I would like to add more entries into "city_data" field as {"t":"x","l":[0.0,0.0,0.0,0.0]} while the "map_data" stays the same. Then I can write the json object into a new file with updates.

To read the json file,
C++
std::ifstream f(file);
json data = json::parse(f);

To retreive "city_data" and then its type and location
C++
json& cityInfo = data["city_data"];
for (unsigned int i = 0; i < cityInfo.size(); i++)
        {
            json& cityType = cityInfo[i];
            std::string ctyTyp = cityType["t"];
            json& cityLoc = cityType["l"];
            std::float_t x = cityLoc[0];
            std::float_t y = cityLoc[1];
            // do something with the retrieved values      
        }
//To retreive map data
ofstream outfile;
outfile.open(m_strFolderPath + m_strFileName + ".png", ofstream::binary);
std::string mapFrame = data["map_data"];
string temp = base64_decode(mapFrame );
outfile.write(temp.c_str(), temp.size());
outfile.close();
f.close();

Any suggestions on how to insert new city_data fields into the nlohmann JSON object? or a way to create a new json file like in above format?
thanks
PKNT


modified 26-Aug-22 14:17pm.

AnswerRe: Using nlohmann JSON to insert more data Pin
Mircea Neacsu26-Aug-22 8:53
Mircea Neacsu26-Aug-22 8:53 
QuestionQuestion About CToolTipCtrl Pin
ForNow24-Aug-22 8:33
ForNow24-Aug-22 8:33 
AnswerRe: Question About CToolTipCtrl Pin
Victor Nijegorodov24-Aug-22 21:53
Victor Nijegorodov24-Aug-22 21:53 
GeneralRe: Question About CToolTipCtrl Pin
ForNow24-Aug-22 22:19
ForNow24-Aug-22 22:19 
GeneralRe: Question About CToolTipCtrl Pin
Victor Nijegorodov24-Aug-22 23:56
Victor Nijegorodov24-Aug-22 23:56 
GeneralRe: Question About CToolTipCtrl Pin
ForNow25-Aug-22 1:36
ForNow25-Aug-22 1:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.