dropbox / json11

A tiny JSON library for C++11.
MIT License
2.55k stars 613 forks source link

support loading already existing json files with provided "std::ifstream: stpe of opened file object. #59

Closed AraHaan closed 8 years ago

AraHaan commented 8 years ago

So, I got a json and the followign code errors rn because soemthing is either wrong is incorrect and yes this must not create the json ONLY read from it. The read data should then be loaded up as a array and iterated through.

ifstream ifile;
int fsize;
char * inBuf;
ifile.open("%UserProfile%\\vbtrpdet database temp\\checkwindow.json", NULL);
ifile.seekg(0, ios::end);
fsize = (int)ifile.tellg();
ifile.seekg(0, ios::beg);
inBuf = new char[fsize];
//Error C2440.
ifile.read(inBuf, fsize);
//Error C2440.
string WINDOW_NAMES = (LPCSTR)ifile;
ifile.close();
//Error C2440.
Json my_json = Json::object { { "detectlist", WINDOW_NAMES } };
while(looping == true) {
    //Error C2660, C2440
    for (auto s : Json::array { Json::object { { "detectlist", Json::array_items(my_json) } } }) {
        //Code to do here for each strign in the json array. (Note: that in my code I use this info to call FindWindow
    };
};
j4cbo commented 8 years ago

It looks like this is an issue with your code, not json11, sorry.