diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc index cbfc7adabb..078d194b76 100644 --- a/src/google/protobuf/util/json_util_test.cc +++ b/src/google/protobuf/util/json_util_test.cc @@ -56,6 +56,7 @@ using proto3::TestEnumValue; using proto3::TestMap; using proto3::TestMessage; using proto3::TestOneof; +using proto3::TestAny; static const char kTypeUrlPrefix[] = "type.googleapis.com"; @@ -357,6 +358,23 @@ TEST_F(JsonUtilTest, TestDynamicMessage) { EXPECT_EQ(ToJson(generated, options), ToJson(*message, options)); } +TEST_F(JsonUtilTest, TestParsingUnknownAnyFields) { + string input = + "{\n" + " \"value\": {\n" + " \"@type\": \"type.googleapis.com/proto3.TestMessage\",\n" + " \"unknown_field\": \"UNKOWN_VALUE\"\n" + " }\n" + "}"; + + TestAny m; + JsonParseOptions options; + EXPECT_FALSE(FromJson(input, &m, options)); + + options.ignore_unknown_fields = true; + EXPECT_TRUE(FromJson(input, &m, options)); +} + TEST_F(JsonUtilTest, TestParsingUnknownEnumsProto2) { string input = "{\n"