@pxt wrote:
Maybe is a very basic question. But i cant figure it out how can i write a Json File using ofxJson.
the basic example only read:
void ofApp::draw() { ofBackground(0); ofSetHexColor(0x00FF00); std::stringstream ss; // { // "firstName": "John", // "lastName": "Smith", ss << "firstName = " << result["firstName"].asString() << std::endl; ss << "lastName = " << result["lastName"].asString() << std::endl; // "age": 25, ss << "age = " << result["age"].asDouble() << endl; // "address": { // "streetAddress": "21 2nd Street", // "city": "New York", // "state": "NY", // "postalCode": "10021" // }, ss << "streetAddress = " << result["address"]["streetAddress"].asString() << std::endl; ss << "city = " << result["address"]["city"].asString() << std::endl; ss << "state = " << result["address"]["state"].asString() << std::endl; ss << "postalCode = " << result["address"]["postalCode"].asString() << std::endl; // "phoneNumber": [ // { // "type": "home", // "number": "212 555-1234" // }, // { // "type": "fax", // "number": "646 555-4567" // } // ] // } int i = 0; ss << "phoneNumber:type = " << result["phoneNumber"][i]["type"].asString() << std::endl; ss << "phoneNumber:number = " << result["phoneNumber"][i]["number"].asString() << std::endl; ss << "phoneNumber:type = " << result["phoneNumber"][i+1]["type"].asString() << std::endl; ss << "phoneNumber:number = " << result["phoneNumber"][i+1]["number"].asString() << std::endl; ofDrawBitmapString(ss.str(), 10, 14); }
how can i write the same file? arrays include.
Thanks a lot!
Posts: 1
Participants: 1