| 27 | } |
| 28 | |
| 29 | void Response::Deserialize(const std::string& json) { |
| 30 | LOG(TRACE) << "Entering Response::Deserialize"; |
| 31 | |
| 32 | Json::Value response_object; |
| 33 | std::string parse_errors; |
| 34 | std::stringstream json_stream; |
| 35 | json_stream.str(json); |
| 36 | Json::parseFromStream(Json::CharReaderBuilder(), |
| 37 | json_stream, |
| 38 | &response_object, |
| 39 | &parse_errors); |
| 40 | |
| 41 | Json::Value value_object; |
| 42 | if (response_object.isMember("value")) { |
| 43 | value_object = response_object["value"]; |
| 44 | if (value_object.isObject() && value_object.isMember("error")) { |
| 45 | this->error_ = value_object["error"].asString(); |
| 46 | this->value_ = value_object["message"].asString(); |
| 47 | if (value_object.isMember("data")) { |
| 48 | this->additional_data_ = value_object["data"]; |
| 49 | } |
| 50 | } else { |
| 51 | this->error_ = ""; |
| 52 | this->value_ = value_object; |
| 53 | } |
| 54 | } else { |
| 55 | this->value_ = Json::Value::null; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | std::string Response::Serialize(void) { |
| 60 | LOG(TRACE) << "Entering Response::Serialize"; |