From bd11198f694a2cb1544992bb7868198b1e9dfe6c Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Tue, 11 Aug 2015 15:07:12 -0700 Subject: Fix map fields parsing. Change-Id: If61e16cea84492474a71bbfe985131ec980b0b0a --- src/google/protobuf/util/internal/protostream_objectwriter.cc | 4 +++- src/google/protobuf/util/json_util_test.cc | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.cc b/src/google/protobuf/util/internal/protostream_objectwriter.cc index f9ddbf32..7f6f3c35 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter.cc +++ b/src/google/protobuf/util/internal/protostream_objectwriter.cc @@ -1541,8 +1541,10 @@ bool ProtoStreamObjectWriter::IsMap(const google::protobuf::Field& field) { const google::protobuf::Type* field_type = typeinfo_->GetType(field.type_url()); + // TODO(xiaofeng): Unify option names. return GetBoolOptionOrDefault(field_type->options(), - "google.protobuf.MessageOptions.map_entry", false); + "google.protobuf.MessageOptions.map_entry", false) || + GetBoolOptionOrDefault(field_type->options(), "map_entry", false); } void ProtoStreamObjectWriter::WriteTag(const google::protobuf::Field& field) { diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc index 8399b408..6686416c 100644 --- a/src/google/protobuf/util/json_util_test.cc +++ b/src/google/protobuf/util/json_util_test.cc @@ -47,6 +47,7 @@ namespace { using proto3::FOO; using proto3::BAR; using proto3::TestMessage; +using proto3::TestMap; static const char kTypeUrlPrefix[] = "type.googleapis.com"; @@ -146,6 +147,16 @@ TEST_F(JsonUtilTest, ParseMessage) { EXPECT_EQ(96, m.repeated_message_value(1).value()); } +TEST_F(JsonUtilTest, ParseMap) { + TestMap message; + (*message.mutable_string_map())["hello"] = 1234; + JsonOptions options; + EXPECT_EQ("{\"stringMap\":{\"hello\":1234}}", ToJson(message, options)); + TestMap other; + ASSERT_TRUE(FromJson(ToJson(message, options), &other)); + EXPECT_EQ(message.DebugString(), other.DebugString()); +} + typedef pair Segment; // A ZeroCopyOutputStream that writes to multiple buffers. class SegmentedZeroCopyOutputStream : public io::ZeroCopyOutputStream { -- cgit v1.2.3 From 72145dffd8cfe737c41e7e7ce194aa7a7e8aa4f2 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 25 Aug 2015 18:41:10 -0700 Subject: include descriptor.proto in nuget package --- csharp/src/Google.Protobuf/Google.Protobuf.nuspec | 1 + 1 file changed, 1 insertion(+) diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.nuspec b/csharp/src/Google.Protobuf/Google.Protobuf.nuspec index 228457a3..9542138a 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.nuspec +++ b/csharp/src/Google.Protobuf/Google.Protobuf.nuspec @@ -23,6 +23,7 @@ + -- cgit v1.2.3