| 75 | } |
| 76 | |
| 77 | json::Object load(const char *filename) |
| 78 | { |
| 79 | // load file to std string |
| 80 | std::ifstream file(filename); |
| 81 | std::stringstream buffer; |
| 82 | buffer << file.rdbuf(); |
| 83 | std::string json = buffer.str(); |
| 84 | |
| 85 | // load rapidjson document |
| 86 | rapidjson::Document document; |
| 87 | document.Parse(json.c_str()); |
| 88 | if (document.HasParseError()) |
| 89 | { |
| 90 | throw std::runtime_error("Failed to parse JSON"); |
| 91 | } |
| 92 | |
| 93 | json::Value result; |
| 94 | convert(document, result); |
| 95 | return std::get<json::Object>(result); |
| 96 | } |
| 97 | |
| 98 | } // namespace |
| 99 | |