| 57 | } |
| 58 | |
| 59 | std::string Response::Serialize(void) { |
| 60 | LOG(TRACE) << "Entering Response::Serialize"; |
| 61 | |
| 62 | Json::Value json_object; |
| 63 | if (this->error_.size() > 0) { |
| 64 | Json::Value error_object; |
| 65 | error_object["error"] = this->error_; |
| 66 | error_object["message"] = this->value_.asString(); |
| 67 | error_object["stacktrace"] = ""; |
| 68 | if (!this->value_.isNull() && !this->additional_data_.isNull()) { |
| 69 | error_object["data"] = this->additional_data_; |
| 70 | } |
| 71 | json_object["value"] = error_object; |
| 72 | } else { |
| 73 | json_object["value"] = this->value_; |
| 74 | } |
| 75 | Json::StreamWriterBuilder writer; |
| 76 | std::string output(Json::writeString(writer, json_object)); |
| 77 | return output; |
| 78 | } |
| 79 | |
| 80 | void Response::SetSuccessResponse(const Json::Value& response_value) { |
| 81 | LOG(TRACE) << "Entering Response::SetSuccessResponse"; |