Skip to content

Commit f4d366e

Browse files
author
voevodskiy
committed
Fix bug in proto2json map empty keys serialization
`<library/cpp/protobuf/json/proto2json.h>` неправильно сериализует пустой ключ protobuf'ной map'ы ``` message TMyMessage { map<string, string> Fields = 1; } ``` При таком протобуфе ``` Fields { key: "" value: "1" } ``` Сейчас получается json ``` { "value": "1" } ``` Хотя должен получаться такой ``` { "": 1 } ``` commit_hash:e678bffbda1a062fa0fcaaba65c2e5f6bf13d558
1 parent b3ffe62 commit f4d366e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/cpp/protobuf/json/proto2json_printer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ namespace NProtobufJson {
253253
bool inProtoMap) {
254254
Y_ABORT_UNLESS(!field.is_repeated(), "field is repeated.");
255255

256-
if (!key) {
256+
if (!key && !inProtoMap) {
257257
key = MakeKey(field);
258258
}
259259

0 commit comments

Comments
 (0)