#include #include #include #include using namespace std; #include "jsoncpp/json/json.h" #include "io.h" #include "restaurant.h" vector parse_file(string filename) { vector restaurants; ifstream infile(filename.c_str()); string file_contents((istreambuf_iterator(infile)), istreambuf_iterator()); Json::Value root; Json::Reader reader; bool good_parse = reader.parse(file_contents, root); if(not good_parse) { throw runtime_error(reader.getFormattedErrorMessages()); } for(unsigned int i = 0; i < root.size(); i++) { string name = root[i]["name"].asString(); int score = root[i]["score"].asInt(); restaurant r(name, score); restaurants.push_back(r); } return restaurants; }