| 41 | #endif |
| 42 | |
| 43 | AnnotatedValue parseAnnotatedValue(const rapidjson::Value& jsonValue) { |
| 44 | AnnotatedValue result; |
| 45 | if (jsonValue.IsObject() && jsonValue.HasMember("value")) { |
| 46 | result = jsonValue["value"].GetString(); |
| 47 | for (const auto& annotation : jsonValue.GetObject()) { |
| 48 | if (annotation.name.GetString() == std::string("value")) { |
| 49 | continue; |
| 50 | } |
| 51 | result.annotations[annotation.name.GetString()] = parseAnnotatedValue(annotation.value); |
| 52 | } |
| 53 | } else if (jsonValue.IsBool()) { |
| 54 | result = jsonValue.GetBool(); |
| 55 | } else { |
| 56 | result = jsonValue.GetString(); |
| 57 | } |
| 58 | return result; |
| 59 | } |
| 60 | |
| 61 | const C2Payload RESTProtocol::parseJsonResponse(const C2Payload &payload, const std::vector<char> &response) { |
| 62 | rapidjson::Document root; |