diff options
author | xveduk <xveduk@yandex-team.ru> | 2022-02-10 16:50:36 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:36 +0300 |
commit | ba437f673c54060a998d3fc113ad4674f6e6422f (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/protobuf | |
parent | 22563fe74eba1fe25e7008e2ec5635bc276eede6 (diff) | |
download | ydb-ba437f673c54060a998d3fc113ad4674f6e6422f.tar.gz |
Restoring authorship annotation for <xveduk@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/protobuf')
-rw-r--r-- | library/cpp/protobuf/json/json2proto.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/library/cpp/protobuf/json/json2proto.cpp b/library/cpp/protobuf/json/json2proto.cpp index 6b7185ab54..640c10f5a5 100644 --- a/library/cpp/protobuf/json/json2proto.cpp +++ b/library/cpp/protobuf/json/json2proto.cpp @@ -139,31 +139,31 @@ JsonEnum2Field(const NJson::TJsonValue& json, const EnumValueDescriptor* enumFieldValue = nullptr; if (json.IsInteger()) { - const auto value = json.GetInteger(); - enumFieldValue = enumField->FindValueByNumber(value); - if (!enumFieldValue) { - ythrow yexception() << "Invalid integer value of JSON enum field: " << value << "."; - } + const auto value = json.GetInteger(); + enumFieldValue = enumField->FindValueByNumber(value); + if (!enumFieldValue) { + ythrow yexception() << "Invalid integer value of JSON enum field: " << value << "."; + } } else if (json.IsString()) { - const auto& value = json.GetString(); + const auto& value = json.GetString(); if (config.EnumValueMode == NProtobufJson::TJson2ProtoConfig::EnumCaseInsensetive) { - enumFieldValue = FindEnumValue(enumField, value, AsciiEqualsIgnoreCase); + enumFieldValue = FindEnumValue(enumField, value, AsciiEqualsIgnoreCase); } else if (config.EnumValueMode == NProtobufJson::TJson2ProtoConfig::EnumSnakeCaseInsensitive) { - enumFieldValue = FindEnumValue(enumField, value, NProtobufJson::EqualsIgnoringCaseAndUnderscores); + enumFieldValue = FindEnumValue(enumField, value, NProtobufJson::EqualsIgnoringCaseAndUnderscores); } else { - enumFieldValue = enumField->FindValueByName(value); + enumFieldValue = enumField->FindValueByName(value); + } + if (!enumFieldValue) { + ythrow yexception() << "Invalid string value of JSON enum field: " << TStringBuf(value).Head(100) << "."; } - if (!enumFieldValue) { - ythrow yexception() << "Invalid string value of JSON enum field: " << TStringBuf(value).Head(100) << "."; - } } else { ythrow yexception() << "Invalid type of JSON enum field: not an integer/string."; } - if (field.is_repeated()) { - reflection->AddEnum(&proto, &field, enumFieldValue); + if (field.is_repeated()) { + reflection->AddEnum(&proto, &field, enumFieldValue); } else { - reflection->SetEnum(&proto, &field, enumFieldValue); + reflection->SetEnum(&proto, &field, enumFieldValue); } } |