diff options
author | Ruslan Kovalev <ruslan.a.kovalev@gmail.com> | 2022-02-10 16:46:44 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:44 +0300 |
commit | 59e19371de37995fcb36beb16cd6ec030af960bc (patch) | |
tree | fa68e36093ebff8b805462e9e6d331fe9d348214 /library/cpp/protobuf | |
parent | 89db6fe2fe2c32d2a832ddfeb04e8d078e301084 (diff) | |
download | ydb-59e19371de37995fcb36beb16cd6ec030af960bc.tar.gz |
Restoring authorship annotation for Ruslan Kovalev <ruslan.a.kovalev@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/protobuf')
-rw-r--r-- | library/cpp/protobuf/json/json2proto.cpp | 14 | ||||
-rw-r--r-- | library/cpp/protobuf/json/ut/json2proto_ut.cpp | 4 |
2 files changed, 9 insertions, 9 deletions
diff --git a/library/cpp/protobuf/json/json2proto.cpp b/library/cpp/protobuf/json/json2proto.cpp index 640c10f5a5..70605275e6 100644 --- a/library/cpp/protobuf/json/json2proto.cpp +++ b/library/cpp/protobuf/json/json2proto.cpp @@ -6,7 +6,7 @@ #include <google/protobuf/message.h> #include <google/protobuf/descriptor.h> -#include <util/generic/hash.h> +#include <util/generic/hash.h> #include <util/generic/maybe.h> #include <util/string/ascii.h> #include <util/string/cast.h> @@ -378,10 +378,10 @@ namespace NProtobufJson { } Y_ENSURE(json.IsMap(), "expected json map"); - + const google::protobuf::Descriptor* descriptor = proto.GetDescriptor(); Y_ASSERT(!!descriptor); - + for (int f = 0, endF = descriptor->field_count(); f < endF; ++f) { const google::protobuf::FieldDescriptor* field = descriptor->field(f); Y_ASSERT(!!field); @@ -391,8 +391,8 @@ namespace NProtobufJson { } else { Json2SingleField(json, proto, *field, config); } - } - + } + if (!config.AllowUnknownFields) { THashMap<TString, bool> knownFields; for (int f = 0, endF = descriptor->field_count(); f < endF; ++f) { @@ -402,8 +402,8 @@ namespace NProtobufJson { for (const auto& f : json.GetMap()) { Y_ENSURE(knownFields.contains(f.first), "unknown field " << f.first); } - } - } + } + } void MergeJson2Proto(const TStringBuf& json, google::protobuf::Message& proto, const TJson2ProtoConfig& config) { NJson::TJsonReaderConfig jsonCfg; diff --git a/library/cpp/protobuf/json/ut/json2proto_ut.cpp b/library/cpp/protobuf/json/ut/json2proto_ut.cpp index 0dfe57bc7a..97333a8986 100644 --- a/library/cpp/protobuf/json/ut/json2proto_ut.cpp +++ b/library/cpp/protobuf/json/ut/json2proto_ut.cpp @@ -506,14 +506,14 @@ class TBytesTransform: public IStringTransform { public: int GetType() const override { return 0; - } + } void Transform(TString&) const override { } void TransformBytes(TString& str) const override { str = "transformed_bytes"; } }; - + Y_UNIT_TEST(TestInvalidJson) { NJson::TJsonValue val{"bad value"}; TFlatOptional proto; |