| 58 | } |
| 59 | |
| 60 | std::string Result::dump() const { |
| 61 | std::string ret; |
| 62 | if (result_json.size() != 0) { |
| 63 | for (auto error : result_json) { |
| 64 | if (error.find("errorcode") == error.end() || !error["errorcode"].is_string() || |
| 65 | error.find("overview") == error.end() || !error["overview"].is_string()) { |
| 66 | return ""; |
| 67 | } |
| 68 | std::string ec = error["errorcode"]; |
| 69 | std::string desc = error["overview"]; |
| 70 | ret += ec + ": " + desc + "\n"; |
| 71 | // recursively display children |
| 72 | auto& data = error["data"]; |
| 73 | ret += prettyPrintJson(data, 1); |
| 74 | } |
| 75 | } |
| 76 | return ret; |
| 77 | } |
| 78 | |
| 79 | int Result::addContext(const nlohmann::json& data) { |
| 80 | static int ctxId = 0; |