aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/protobuf/json
diff options
context:
space:
mode:
authorAlexSm <alex@ydb.tech>2023-12-27 23:31:58 +0100
committerGitHub <noreply@github.com>2023-12-27 23:31:58 +0100
commitd67bfb4b4b7549081543e87a31bc6cb5c46ac973 (patch)
tree8674f2f1570877cb653e7ddcff37ba00288de15a /library/cpp/protobuf/json
parent1f6bef05ed441c3aa2d565ac792b26cded704ac7 (diff)
downloadydb-d67bfb4b4b7549081543e87a31bc6cb5c46ac973.tar.gz
Import libs 4 (#758)
Diffstat (limited to 'library/cpp/protobuf/json')
-rw-r--r--library/cpp/protobuf/json/json2proto.cpp10
-rw-r--r--library/cpp/protobuf/json/proto2json_printer.cpp4
2 files changed, 7 insertions, 7 deletions
diff --git a/library/cpp/protobuf/json/json2proto.cpp b/library/cpp/protobuf/json/json2proto.cpp
index 83b7891b9c0..f0ca3adf42e 100644
--- a/library/cpp/protobuf/json/json2proto.cpp
+++ b/library/cpp/protobuf/json/json2proto.cpp
@@ -367,7 +367,7 @@ Json2RepeatedFieldValue(const NJson::TJsonValue& jsonValue,
const google::protobuf::FieldDescriptor& field,
const NProtobufJson::TJson2ProtoConfig& config,
const google::protobuf::Reflection* reflection,
- const TMaybe<TString>& key = {}) {
+ const TString* key = nullptr) {
using namespace google::protobuf;
switch (field.cpp_type()) {
@@ -392,12 +392,12 @@ Json2RepeatedFieldValue(const NJson::TJsonValue& jsonValue,
case FieldDescriptor::CPPTYPE_MESSAGE: {
Message* innerProto = reflection->AddMessage(&proto, &field);
Y_ASSERT(!!innerProto);
- if (key.Defined()) {
- const FieldDescriptor* keyField = innerProto->GetDescriptor()->FindFieldByName("key");
+ if (key) {
+ const FieldDescriptor* keyField = innerProto->GetDescriptor()->map_key();
Y_ENSURE(keyField, "Map entry key field not found: " << field.name());
SetKey(*innerProto, *keyField, *key);
- const FieldDescriptor* valueField = innerProto->GetDescriptor()->FindFieldByName("value");
+ const FieldDescriptor* valueField = innerProto->GetDescriptor()->map_value();
Y_ENSURE(valueField, "Map entry value field not found.");
Json2SingleField(jsonValue, *innerProto, *valueField, config, /*isMapValue=*/true);
} else {
@@ -457,7 +457,7 @@ Json2RepeatedField(const NJson::TJsonValue& json,
if (config.UnknownFieldsCollector) {
config.UnknownFieldsCollector->OnEnterMapItem(key);
}
- Json2RepeatedFieldValue(jsonValue, proto, field, config, reflection, key);
+ Json2RepeatedFieldValue(jsonValue, proto, field, config, reflection, &key);
if (config.UnknownFieldsCollector) {
config.UnknownFieldsCollector->OnLeaveMapItem();
}
diff --git a/library/cpp/protobuf/json/proto2json_printer.cpp b/library/cpp/protobuf/json/proto2json_printer.cpp
index aa0823de0ed..b2426f395a0 100644
--- a/library/cpp/protobuf/json/proto2json_printer.cpp
+++ b/library/cpp/protobuf/json/proto2json_printer.cpp
@@ -408,10 +408,10 @@ namespace NProtobufJson {
void TProto2JsonPrinter::PrintKeyValue(const NProtoBuf::Message& proto,
IJsonOutput& json) {
- const FieldDescriptor* keyField = proto.GetDescriptor()->FindFieldByName("key");
+ const FieldDescriptor* keyField = proto.GetDescriptor()->map_key();
Y_ABORT_UNLESS(keyField, "Map entry key field not found.");
TString key = MakeKey(proto, *keyField);
- const FieldDescriptor* valueField = proto.GetDescriptor()->FindFieldByName("value");
+ const FieldDescriptor* valueField = proto.GetDescriptor()->map_value();
Y_ABORT_UNLESS(valueField, "Map entry value field not found.");
PrintSingleField(proto, *valueField, json, key, true);
}