aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/protobuf/json/proto2json_printer.cpp
diff options
context:
space:
mode:
authorart-snake <art-snake@yandex-team.ru>2022-02-10 16:50:35 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:35 +0300
commitdc5517df41fe6319ff249956fe5650e4bbc3e660 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/protobuf/json/proto2json_printer.cpp
parent1700010e2088971894d12a7a16d6004866f986fd (diff)
downloadydb-dc5517df41fe6319ff249956fe5650e4bbc3e660.tar.gz
Restoring authorship annotation for <art-snake@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/protobuf/json/proto2json_printer.cpp')
-rw-r--r--library/cpp/protobuf/json/proto2json_printer.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/library/cpp/protobuf/json/proto2json_printer.cpp b/library/cpp/protobuf/json/proto2json_printer.cpp
index 69a0aa25f6..6123eab0f2 100644
--- a/library/cpp/protobuf/json/proto2json_printer.cpp
+++ b/library/cpp/protobuf/json/proto2json_printer.cpp
@@ -205,18 +205,18 @@ namespace NProtobufJson {
const Reflection* reflection = proto.GetReflection();
- bool shouldPrintField = reflection->HasField(proto, &field);
- if (!shouldPrintField && GetConfig().MissingSingleKeyMode == TProto2JsonConfig::MissingKeyExplicitDefaultThrowRequired) {
- if (field.has_default_value()) {
- shouldPrintField = true;
- } else if (field.is_required()) {
- ythrow yexception() << "Empty required protobuf field: "
- << field.full_name() << ".";
- }
- }
- shouldPrintField = shouldPrintField || GetConfig().MissingSingleKeyMode == TProto2JsonConfig::MissingKeyDefault;
-
- if (shouldPrintField) {
+ bool shouldPrintField = reflection->HasField(proto, &field);
+ if (!shouldPrintField && GetConfig().MissingSingleKeyMode == TProto2JsonConfig::MissingKeyExplicitDefaultThrowRequired) {
+ if (field.has_default_value()) {
+ shouldPrintField = true;
+ } else if (field.is_required()) {
+ ythrow yexception() << "Empty required protobuf field: "
+ << field.full_name() << ".";
+ }
+ }
+ shouldPrintField = shouldPrintField || GetConfig().MissingSingleKeyMode == TProto2JsonConfig::MissingKeyDefault;
+
+ if (shouldPrintField) {
switch (field.cpp_type()) {
INT_FIELD_TO_JSON(CPPTYPE_INT32, GetInt32);
INT_FIELD_TO_JSON(CPPTYPE_INT64, GetInt64);
@@ -256,7 +256,7 @@ namespace NProtobufJson {
}
case TProto2JsonConfig::MissingKeySkip:
- case TProto2JsonConfig::MissingKeyExplicitDefaultThrowRequired:
+ case TProto2JsonConfig::MissingKeyExplicitDefaultThrowRequired:
default:
break;
}
@@ -358,7 +358,7 @@ namespace NProtobufJson {
}
case TProto2JsonConfig::MissingKeySkip:
- case TProto2JsonConfig::MissingKeyExplicitDefaultThrowRequired:
+ case TProto2JsonConfig::MissingKeyExplicitDefaultThrowRequired:
default:
break;
}