MCPcopy Create free account
hub / github.com/catboost/catboost / AreJsonMapsEqual

Function AreJsonMapsEqual

library/cpp/json/writer/json_value.cpp:17–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#include <util/generic/yexception.h>
16
17static bool
18AreJsonMapsEqual(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
45static bool
46AreJsonArraysEqual(const NJson::TJsonValue& lhs, const NJson::TJsonValue& rhs) {

Callers 1

operator==Method · 0.70

Calls 5

GetTypeMethod · 0.45
GetMapMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected