1// Protocol Buffers - Google's data interchange format 2// Copyright 2008 Google Inc. All rights reserved. 3// 4// Use of this source code is governed by a BSD-style 5// license that can be found in the LICENSE file or at 6// https://developers.google.com/open-source/licenses/bsd 7 8syntax = "proto3"; 9 10package proto3; 11 12import "google/protobuf/any.proto"; 13import "google/protobuf/duration.proto"; 14import "google/protobuf/field_mask.proto"; 15import "google/protobuf/struct.proto"; 16import "google/protobuf/timestamp.proto"; 17import "google/protobuf/wrappers.proto"; 18import "google/protobuf/unittest.proto"; 19 20option java_package = "com.google.protobuf.util"; 21option java_outer_classname = "JsonFormatProto3"; 22 23enum EnumType { 24 FOO = 0; 25 BAR = 1; 26 TLSv1_2 = 2; 27} 28 29message MessageType { 30 int32 value = 1; 31} 32 33message TestMessage { 34 bool bool_value = 1; 35 int32 int32_value = 2; 36 int64 int64_value = 3; 37 uint32 uint32_value = 4; 38 uint64 uint64_value = 5; 39 float float_value = 6; 40 double double_value = 7; 41 string string_value = 8; 42 bytes bytes_value = 9; 43 EnumType enum_value = 10; 44 MessageType message_value = 11; 45 46 repeated bool repeated_bool_value = 21; 47 repeated int32 repeated_int32_value = 22; 48 repeated int64 repeated_int64_value = 23; 49 repeated uint32 repeated_uint32_value = 24; 50 repeated uint64 repeated_uint64_value = 25; 51 repeated float repeated_float_value = 26; 52 repeated double repeated_double_value = 27; 53 repeated string repeated_string_value = 28; 54 repeated bytes repeated_bytes_value = 29; 55 repeated EnumType repeated_enum_value = 30; 56 repeated MessageType repeated_message_value = 31; 57 58 optional bool optional_bool_value = 41; 59 optional int32 optional_int32_value = 42; 60 optional int64 optional_int64_value = 43; 61 optional uint32 optional_uint32_value = 44; 62 optional uint64 optional_uint64_value = 45; 63 optional float optional_float_value = 46; 64 optional double optional_double_value = 47; 65 optional string optional_string_value = 48; 66 optional bytes optional_bytes_value = 49; 67 optional EnumType optional_enum_value = 50; 68 optional MessageType optional_message_value = 51; 69} 70 71message TestOneof { 72 // In JSON format oneof fields behave mostly the same as optional 73 // fields except that: 74 // 1. Oneof fields have field presence information and will be 75 // printed if it's set no matter whether it's the default value. 76 // 2. Multiple oneof fields in the same oneof cannot appear at the 77 // same time in the input. 78 oneof oneof_value { 79 int32 oneof_int32_value = 1; 80 string oneof_string_value = 2; 81 bytes oneof_bytes_value = 3; 82 EnumType oneof_enum_value = 4; 83 MessageType oneof_message_value = 5; 84 google.protobuf.NullValue oneof_null_value = 6; 85 } 86} 87 88message TestMap { 89 map<bool, int32> bool_map = 1; 90 map<int32, int32> int32_map = 2; 91 map<int64, int32> int64_map = 3; 92 map<uint32, int32> uint32_map = 4; 93 map<uint64, int32> uint64_map = 5; 94 map<string, int32> string_map = 6; 95} 96 97message TestNestedMap { 98 map<bool, int32> bool_map = 1; 99 map<int32, int32> int32_map = 2; 100 map<int64, int32> int64_map = 3; 101 map<uint32, int32> uint32_map = 4; 102 map<uint64, int32> uint64_map = 5; 103 map<string, int32> string_map = 6; 104 map<string, TestNestedMap> map_map = 7; 105} 106 107message TestStringMap { 108 map<string, string> string_map = 1; 109} 110 111message TestWrapper { 112 google.protobuf.BoolValue bool_value = 1; 113 google.protobuf.Int32Value int32_value = 2; 114 google.protobuf.Int64Value int64_value = 3; 115 google.protobuf.UInt32Value uint32_value = 4; 116 google.protobuf.UInt64Value uint64_value = 5; 117 google.protobuf.FloatValue float_value = 6; 118 google.protobuf.DoubleValue double_value = 7; 119 google.protobuf.StringValue string_value = 8; 120 google.protobuf.BytesValue bytes_value = 9; 121 122 repeated google.protobuf.BoolValue repeated_bool_value = 11; 123 repeated google.protobuf.Int32Value repeated_int32_value = 12; 124 repeated google.protobuf.Int64Value repeated_int64_value = 13; 125 repeated google.protobuf.UInt32Value repeated_uint32_value = 14; 126 repeated google.protobuf.UInt64Value repeated_uint64_value = 15; 127 repeated google.protobuf.FloatValue repeated_float_value = 16; 128 repeated google.protobuf.DoubleValue repeated_double_value = 17; 129 repeated google.protobuf.StringValue repeated_string_value = 18; 130 repeated google.protobuf.BytesValue repeated_bytes_value = 19; 131} 132 133message TestTimestamp { 134 google.protobuf.Timestamp value = 1; 135 repeated google.protobuf.Timestamp repeated_value = 2; 136} 137 138message TestDuration { 139 google.protobuf.Duration value = 1; 140 repeated google.protobuf.Duration repeated_value = 2; 141} 142 143message TestFieldMask { 144 google.protobuf.FieldMask value = 1; 145} 146 147message TestStruct { 148 google.protobuf.Struct value = 1; 149 repeated google.protobuf.Struct repeated_value = 2; 150} 151 152message TestAny { 153 google.protobuf.Any value = 1; 154 repeated google.protobuf.Any repeated_value = 2; 155} 156 157message TestValue { 158 google.protobuf.Value value = 1; 159 repeated google.protobuf.Value repeated_value = 2; 160} 161 162message TestListValue { 163 google.protobuf.ListValue value = 1; 164 repeated google.protobuf.ListValue repeated_value = 2; 165} 166 167message TestBoolValue { 168 bool bool_value = 1; 169 map<bool, int32> bool_map = 2; 170} 171 172message TestNullValue { 173 google.protobuf.NullValue null_value = 20; 174 repeated google.protobuf.NullValue repeated_null_value = 21; 175} 176 177message TestCustomJsonName { 178 int32 value = 1 [json_name = "@value"]; 179} 180 181message TestEvilJson { 182 int32 regular_value = 1 [json_name = "regular_name"]; 183 int32 script = 2 [json_name = "</script>"]; 184 int32 quotes = 3 [json_name = "unbalanced\"quotes"]; 185 int32 script_and_quotes = 4 186 [json_name = "\"<script>alert('hello!);</script>"]; 187} 188 189message TestExtensions { 190 .protobuf_unittest.TestAllExtensions extensions = 1; 191} 192 193message TestEnumValue { 194 EnumType enum_value1 = 1; 195 EnumType enum_value2 = 2; 196 EnumType enum_value3 = 3; 197} 198 199message MapsTestCases { 200 EmptyMap empty_map = 1; 201 StringtoInt string_to_int = 2; 202 IntToString int_to_string = 3; 203 Mixed1 mixed1 = 4; 204 Mixed2 mixed2 = 5; 205 MapOfObjects map_of_objects = 6; 206 207 // Empty key tests 208 StringtoInt empty_key_string_to_int1 = 7; 209 StringtoInt empty_key_string_to_int2 = 8; 210 StringtoInt empty_key_string_to_int3 = 9; 211 BoolToString empty_key_bool_to_string = 10; 212 IntToString empty_key_int_to_string = 11; 213 Mixed1 empty_key_mixed = 12; 214 MapOfObjects empty_key_map_objects = 13; 215} 216 217message EmptyMap { 218 map<int32, int32> map = 1; 219} 220 221message StringtoInt { 222 map<string, int32> map = 1; 223} 224 225message IntToString { 226 map<int32, string> map = 1; 227} 228 229message BoolToString { 230 map<bool, string> map = 1; 231} 232 233message Mixed1 { 234 string msg = 1; 235 map<string, float> map = 2; 236} 237 238message Mixed2 { 239 enum E { 240 E0 = 0; 241 E1 = 1; 242 E2 = 2; 243 E3 = 3; 244 } 245 map<int32, bool> map = 1; 246 E ee = 2; 247} 248 249message MapOfObjects { 250 message M { 251 string inner_text = 1; 252 } 253 map<string, M> map = 1; 254} 255 256message MapOfEnums { 257 map<string, EnumType> map = 1; 258} 259 260message MapIn { 261 string other = 1; 262 repeated string things = 2; 263 map<string, string> map_input = 3; 264 map<string, google.protobuf.Any> map_any = 4; 265} 266 267message MapOut { 268 map<string, MapM> map1 = 1; 269 map<string, MapOut> map2 = 2; 270 map<int32, string> map3 = 3; 271 map<bool, string> map4 = 5; 272 string bar = 4; 273} 274 275// A message with exactly the same wire representation as MapOut, but using 276// repeated message fields instead of map fields. We use this message to test 277// the wire-format compatibility of the JSON transcoder (e.g., whether it 278// handles missing keys correctly). 279message MapOutWireFormat { 280 message Map1Entry { 281 string key = 1; 282 MapM value = 2; 283 } 284 repeated Map1Entry map1 = 1; 285 message Map2Entry { 286 string key = 1; 287 MapOut value = 2; 288 } 289 repeated Map2Entry map2 = 2; 290 message Map3Entry { 291 int32 key = 1; 292 string value = 2; 293 } 294 repeated Map3Entry map3 = 3; 295 message Map4Entry { 296 bool key = 1; 297 string value = 2; 298 } 299 repeated Map4Entry map4 = 5; 300 string bar = 4; 301} 302 303message MapM { 304 string foo = 1; 305} 306