| 15 | #include <util/generic/yexception.h> |
| 16 | |
| 17 | static bool |
| 18 | AreJsonMapsEqual(const NJson::TJsonValue& lhs, const NJson::TJsonValue& rhs) { |
| 19 | using namespace NJson; |
| 20 | |
| 21 | Y_ABORT_UNLESS(lhs.GetType() == JSON_MAP, "lhs has not a JSON_MAP type."); |
| 22 | |
| 23 | if (rhs.GetType() != JSON_MAP) { |
| 24 | return false; |
| 25 | } |
| 26 | typedef TJsonValue::TMapType TMapType; |
| 27 | const TMapType& lhsMap = lhs.GetMap(); |
| 28 | const TMapType& rhsMap = rhs.GetMap(); |
| 29 | |
| 30 | if (lhsMap.size() != rhsMap.size()) { |
| 31 | return false; |
| 32 | } |
| 33 | for (const auto& lhsIt : lhsMap) { |
| 34 | TMapType::const_iterator rhsIt = rhsMap.find(lhsIt.first); |
| 35 | if (rhsIt == rhsMap.end()) { |
| 36 | return false; |
| 37 | } |
| 38 | if (lhsIt.second != rhsIt->second) { |
| 39 | return false; |
| 40 | } |
| 41 | } |
| 42 | return true; |
| 43 | } |
| 44 | |
| 45 | static bool |
| 46 | AreJsonArraysEqual(const NJson::TJsonValue& lhs, const NJson::TJsonValue& rhs) { |