diff options
author | kelarev <kelarev@yandex-team.ru> | 2022-02-10 16:50:25 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:25 +0300 |
commit | 2b7a11999a854601a22b47b483fd03a7de5bfd90 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/json | |
parent | 3f71754853b8ed102c9371ac075aa81274a39b9b (diff) | |
download | ydb-2b7a11999a854601a22b47b483fd03a7de5bfd90.tar.gz |
Restoring authorship annotation for <kelarev@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/json')
-rw-r--r-- | library/cpp/json/writer/json_value.cpp | 8 | ||||
-rw-r--r-- | library/cpp/json/writer/json_value_ut.cpp | 50 |
2 files changed, 29 insertions, 29 deletions
diff --git a/library/cpp/json/writer/json_value.cpp b/library/cpp/json/writer/json_value.cpp index a21a2f1cc9..c61e8d1dc4 100644 --- a/library/cpp/json/writer/json_value.cpp +++ b/library/cpp/json/writer/json_value.cpp @@ -869,8 +869,8 @@ namespace NJson { return true; } return false; - } - + } + bool TJsonValue::SetValueByPath(const TStringBuf path, TJsonValue&& value, char delimiter) { TJsonValue* const ptr = GetValuePtrByPath<true>(this, path, delimiter); if (ptr) { @@ -878,8 +878,8 @@ namespace NJson { return true; } return false; - } - + } + const TJsonValue* TJsonValue::GetValueByPath(const TStringBuf key, char delim) const noexcept { return GetValuePtrByPath<false>(this, key, delim); } diff --git a/library/cpp/json/writer/json_value_ut.cpp b/library/cpp/json/writer/json_value_ut.cpp index d8c7f00124..dc7f6affdf 100644 --- a/library/cpp/json/writer/json_value_ut.cpp +++ b/library/cpp/json/writer/json_value_ut.cpp @@ -245,10 +245,10 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { lhs.InsertValue("l", last); TJsonValue result; - UNIT_ASSERT(lhs.GetValueByPath("l/a/c/e", result, '/')); + UNIT_ASSERT(lhs.GetValueByPath("l/a/c/e", result, '/')); UNIT_ASSERT(result.GetStringRobust() == "f"); - UNIT_ASSERT(!lhs.GetValueByPath("l/a/c/se", result, '/')); - UNIT_ASSERT(lhs.GetValueByPath("l/a/c", result, '/')); + UNIT_ASSERT(!lhs.GetValueByPath("l/a/c/se", result, '/')); + UNIT_ASSERT(lhs.GetValueByPath("l/a/c", result, '/')); UNIT_ASSERT(result.GetStringRobust() == "{\"e\":\"f\"}"); // faster TStringBuf version @@ -260,28 +260,28 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT_EQUAL(lhs.GetValueByPath("a/c/e/x", '/'), NULL); UNIT_ASSERT_EQUAL(lhs.GetValueByPath("nokey", '/'), NULL); UNIT_ASSERT_EQUAL(*lhs.GetValueByPath("", '/'), lhs); // itself - - TJsonValue array; - TJsonValue third; - array[0] = first; - array[1] = second; - third["t"] = array; - - UNIT_ASSERT(array.GetValueByPath("[0].e", result)); - UNIT_ASSERT(result.GetStringRobust() == "f"); - UNIT_ASSERT(third.GetValueByPath("t.[0].e", result)); - UNIT_ASSERT(result.GetStringRobust() == "f"); - UNIT_ASSERT(third.GetValueByPath("t.[1].c.e", result)); - UNIT_ASSERT(result.GetStringRobust() == "f"); - UNIT_ASSERT(!third.GetValueByPath("t.[2]", result)); - - UNIT_ASSERT(third.SetValueByPath("t.[2]", "g")); - UNIT_ASSERT(third.GetValueByPath("t.[2]", result)); - UNIT_ASSERT(result.GetStringRobust() == "g"); - - UNIT_ASSERT(lhs.SetValueByPath("l/a/c/se", "h", '/')); - UNIT_ASSERT(lhs.GetValueByPath("l/a/c/se", result, '/')); - UNIT_ASSERT(result.GetStringRobust() == "h"); + + TJsonValue array; + TJsonValue third; + array[0] = first; + array[1] = second; + third["t"] = array; + + UNIT_ASSERT(array.GetValueByPath("[0].e", result)); + UNIT_ASSERT(result.GetStringRobust() == "f"); + UNIT_ASSERT(third.GetValueByPath("t.[0].e", result)); + UNIT_ASSERT(result.GetStringRobust() == "f"); + UNIT_ASSERT(third.GetValueByPath("t.[1].c.e", result)); + UNIT_ASSERT(result.GetStringRobust() == "f"); + UNIT_ASSERT(!third.GetValueByPath("t.[2]", result)); + + UNIT_ASSERT(third.SetValueByPath("t.[2]", "g")); + UNIT_ASSERT(third.GetValueByPath("t.[2]", result)); + UNIT_ASSERT(result.GetStringRobust() == "g"); + + UNIT_ASSERT(lhs.SetValueByPath("l/a/c/se", "h", '/')); + UNIT_ASSERT(lhs.GetValueByPath("l/a/c/se", result, '/')); + UNIT_ASSERT(result.GetStringRobust() == "h"); } } |