@stephanschulz wrote:
I like using the forum as note book. Here some code that shows how to parse the content of a json file.
//-------------------------------------------------------------- void ofApp::setup(){ //https://github.com/nlohmann/json string _fixtureBrand = "UKING"; string _fixtureName = "RGBW"; std::string path = ofToDataPath( "fixtures/"+_fixtureName+".json" ); ofFile file( path ); if( file.exists() ){ ofLog() << "found file = "<<path<<", loading"; ofJson json = ofLoadJson( path ); // ofLog()<<json.size(); // ofLog()<<json.back(); string json_string = json.dump(); ofLog()<<"json_string "<<json_string; ofLog << json[_fixtureBrand][_fixtureName]["PAN"]; }else{ ofLog() << "file not found for state name = "<<path; } }
My json file looks like this:
Posts: 1
Participants: 1