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 | 3f71754853b8ed102c9371ac075aa81274a39b9b (patch) | |
tree | fabf3a51c2c43e55573ec287c5d8a17a2206cf07 /library/cpp/json/writer | |
parent | 054d233fbefc50c1a88d0e4092c192bfbec99826 (diff) | |
download | ydb-3f71754853b8ed102c9371ac075aa81274a39b9b.tar.gz |
Restoring authorship annotation for <kelarev@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/json/writer')
-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 c61e8d1dc4..a21a2f1cc9 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 dc7f6affdf..d8c7f00124 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"); } } |