diff --git a/packages/protobuf-test/extra/json_types.proto b/packages/protobuf-test/extra/json_types.proto index 0aa948069..b58e53716 100644 --- a/packages/protobuf-test/extra/json_types.proto +++ b/packages/protobuf-test/extra/json_types.proto @@ -50,6 +50,14 @@ message JsonTypesMessage { google.protobuf.BytesValue wrapped_bytes_field = 24; repeated JsonTypeEnum repeated_enum_field = 25; map map_bool_enum_field = 26; + bool json_name_ok = 27 [json_name = "Foo123_bar$"]; + bool json_name_at = 28 [json_name = "foo@"]; + bool json_name_hyphen = 29 [json_name = "foo-bar"]; + bool json_name_start_with_digit = 30 [json_name = "1foo"]; + bool json_name_space = 31 [json_name = "foo bar"]; + bool json_name_tab = 32 [json_name = "foo\tbar"]; + bool json_name_non_ascii = 33 [json_name = "你好"]; + bool json_name_escape = 34 [json_name = "foo\nbar\\n"]; } enum JsonTypeEnum { diff --git a/packages/protobuf-test/src/gen/js,json_types/extra/json_types_pb.d.ts b/packages/protobuf-test/src/gen/js,json_types/extra/json_types_pb.d.ts index 9c061b74b..a9389f5cf 100644 --- a/packages/protobuf-test/src/gen/js,json_types/extra/json_types_pb.d.ts +++ b/packages/protobuf-test/src/gen/js,json_types/extra/json_types_pb.d.ts @@ -158,6 +158,47 @@ export declare type JsonTypesMessage = Message<"spec.JsonTypesMessage"> & { * @generated from field: map map_bool_enum_field = 26; */ mapBoolEnumField: { [key: string]: JsonTypeEnum }; + + /** + * @generated from field: bool json_name_ok = 27 [json_name = "Foo123_bar$"]; + */ + jsonNameOk: boolean; + + /** + * @generated from field: bool json_name_at = 28 [json_name = "foo@"]; + */ + jsonNameAt: boolean; + + /** + * @generated from field: bool json_name_hyphen = 29 [json_name = "foo-bar"]; + */ + jsonNameHyphen: boolean; + + /** + * @generated from field: bool json_name_start_with_digit = 30 [json_name = "1foo"]; + */ + jsonNameStartWithDigit: boolean; + + /** + * @generated from field: bool json_name_space = 31 [json_name = "foo bar"]; + */ + jsonNameSpace: boolean; + + /** + * @generated from field: bool json_name_tab = 32 [json_name = "foo bar"]; + */ + jsonNameTab: boolean; + + /** + * @generated from field: bool json_name_non_ascii = 33 [json_name = "你好"]; + */ + jsonNameNonAscii: boolean; + + /** + * @generated from field: bool json_name_escape = 34 [json_name = "foo + * bar\n"]; + */ + jsonNameEscape: boolean; }; /** @@ -293,6 +334,47 @@ export declare type JsonTypesMessageJson = { * @generated from field: map map_bool_enum_field = 26; */ mapBoolEnumField?: { [key: string]: JsonTypeEnumJson }; + + /** + * @generated from field: bool json_name_ok = 27 [json_name = "Foo123_bar$"]; + */ + Foo123_bar$?: boolean; + + /** + * @generated from field: bool json_name_at = 28 [json_name = "foo@"]; + */ + "foo@"?: boolean; + + /** + * @generated from field: bool json_name_hyphen = 29 [json_name = "foo-bar"]; + */ + "foo-bar"?: boolean; + + /** + * @generated from field: bool json_name_start_with_digit = 30 [json_name = "1foo"]; + */ + "1foo"?: boolean; + + /** + * @generated from field: bool json_name_space = 31 [json_name = "foo bar"]; + */ + "foo bar"?: boolean; + + /** + * @generated from field: bool json_name_tab = 32 [json_name = "foo bar"]; + */ + "foo bar"?: boolean; + + /** + * @generated from field: bool json_name_non_ascii = 33 [json_name = "你好"]; + */ + "你好"?: boolean; + + /** + * @generated from field: bool json_name_escape = 34 [json_name = "foo + * bar\n"]; + */ + "foo\nbar\\n"?: boolean; }; /** diff --git a/packages/protobuf-test/src/gen/js,json_types/extra/json_types_pb.js b/packages/protobuf-test/src/gen/js,json_types/extra/json_types_pb.js index 91bf7588a..f8ba9e9b8 100644 --- a/packages/protobuf-test/src/gen/js,json_types/extra/json_types_pb.js +++ b/packages/protobuf-test/src/gen/js,json_types/extra/json_types_pb.js @@ -23,7 +23,7 @@ import { file_google_protobuf_any, file_google_protobuf_duration, file_google_pr * Describes the file extra/json_types.proto. */ export const file_extra_json_types = /*@__PURE__*/ - fileDesc("ChZleHRyYS9qc29uX3R5cGVzLnByb3RvEgRzcGVjIu4KChBKc29uVHlwZXNNZXNzYWdlEi4KCmJvb2xfZmllbGQYASABKAhSG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VlEjoKFHdyYXBwZWRfdWludDY0X2ZpZWxkGBMgASgLMhwuZ29vZ2xlLnByb3RvYnVmLlVJbnQ2NFZhbHVlEjgKE3dyYXBwZWRfaW50MzJfZmllbGQYFCABKAsyGy5nb29nbGUucHJvdG9idWYuSW50MzJWYWx1ZRI6ChR3cmFwcGVkX3VpbnQzMl9maWVsZBgVIAEoCzIcLmdvb2dsZS5wcm90b2J1Zi5VSW50MzJWYWx1ZRI2ChJ3cmFwcGVkX2Jvb2xfZmllbGQYFiABKAsyGi5nb29nbGUucHJvdG9idWYuQm9vbFZhbHVlEjoKFHdyYXBwZWRfc3RyaW5nX2ZpZWxkGBcgASgLMhwuZ29vZ2xlLnByb3RvYnVmLlN0cmluZ1ZhbHVlEjgKE3dyYXBwZWRfYnl0ZXNfZmllbGQYGCABKAsyGy5nb29nbGUucHJvdG9idWYuQnl0ZXNWYWx1ZRIvChNyZXBlYXRlZF9lbnVtX2ZpZWxkGBkgAygOMhIuc3BlYy5Kc29uVHlwZUVudW0SSQoTbWFwX2Jvb2xfZW51bV9maWVsZBgaIAMoCzIsLnNwZWMuSnNvblR5cGVzTWVzc2FnZS5NYXBCb29sRW51bUZpZWxkRW50cnkaSwoVTWFwQm9vbEVudW1GaWVsZEVudHJ5EgsKA2tleRgBIAEoCBIhCgV2YWx1ZRgCIAEoDjISLnNwZWMuSnNvblR5cGVFbnVtOgI4ASpdCgxKc29uVHlwZUVudW0SHgoaSlNPTl9UWVBFX0VOVU1fVU5TUEVDSUZJRUQQABIWChJKU09OX1RZUEVfRU5VTV9ZRVMQARIVChFKU09OX1RZUEVfRU5VTV9OTxACYgZwcm90bzM", [file_google_protobuf_any, file_google_protobuf_duration, file_google_protobuf_empty, file_google_protobuf_field_mask, file_google_protobuf_struct, file_google_protobuf_timestamp, file_google_protobuf_wrappers]); + fileDesc("ChZleHRyYS9qc29uX3R5cGVzLnByb3RvEgRzcGVjIoYNChBKc29uVHlwZXNNZXNzYWdlEi4KCmJvb2xfZmllb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QoFdmFsdWUYAiABKA4yEi5zcGVjLkpzb25UeXBlRW51bToCOAEqXQoMSnNvblR5cGVFbnVtEh4KGkpTT05fVFlQRV9FTlVNX1VOU1BFQ0lGSUVEEAASFgoSSlNPTl9UWVBFX0VOVU1fWUVTEAESFQoRSlNPTl9UWVBFX0VOVU1fTk8QAmIGcHJvdG8z", [file_google_protobuf_any, file_google_protobuf_duration, file_google_protobuf_empty, file_google_protobuf_field_mask, file_google_protobuf_struct, file_google_protobuf_timestamp, file_google_protobuf_wrappers]); /** * Describes the message spec.JsonTypesMessage. diff --git a/packages/protobuf-test/src/gen/js/extra/json_types_pb.d.ts b/packages/protobuf-test/src/gen/js/extra/json_types_pb.d.ts index 4db7e65a8..a840f3670 100644 --- a/packages/protobuf-test/src/gen/js/extra/json_types_pb.d.ts +++ b/packages/protobuf-test/src/gen/js/extra/json_types_pb.d.ts @@ -158,6 +158,47 @@ export declare type JsonTypesMessage = Message<"spec.JsonTypesMessage"> & { * @generated from field: map map_bool_enum_field = 26; */ mapBoolEnumField: { [key: string]: JsonTypeEnum }; + + /** + * @generated from field: bool json_name_ok = 27 [json_name = "Foo123_bar$"]; + */ + jsonNameOk: boolean; + + /** + * @generated from field: bool json_name_at = 28 [json_name = "foo@"]; + */ + jsonNameAt: boolean; + + /** + * @generated from field: bool json_name_hyphen = 29 [json_name = "foo-bar"]; + */ + jsonNameHyphen: boolean; + + /** + * @generated from field: bool json_name_start_with_digit = 30 [json_name = "1foo"]; + */ + jsonNameStartWithDigit: boolean; + + /** + * @generated from field: bool json_name_space = 31 [json_name = "foo bar"]; + */ + jsonNameSpace: boolean; + + /** + * @generated from field: bool json_name_tab = 32 [json_name = "foo bar"]; + */ + jsonNameTab: boolean; + + /** + * @generated from field: bool json_name_non_ascii = 33 [json_name = "你好"]; + */ + jsonNameNonAscii: boolean; + + /** + * @generated from field: bool json_name_escape = 34 [json_name = "foo + * bar\n"]; + */ + jsonNameEscape: boolean; }; /** diff --git a/packages/protobuf-test/src/gen/js/extra/json_types_pb.js b/packages/protobuf-test/src/gen/js/extra/json_types_pb.js index 78147c12e..b97e6cfd3 100644 --- a/packages/protobuf-test/src/gen/js/extra/json_types_pb.js +++ b/packages/protobuf-test/src/gen/js/extra/json_types_pb.js @@ -23,7 +23,7 @@ import { file_google_protobuf_any, file_google_protobuf_duration, file_google_pr * Describes the file extra/json_types.proto. */ export const file_extra_json_types = /*@__PURE__*/ - fileDesc("ChZleHRyYS9qc29uX3R5cGVzLnByb3RvEgRzcGVjIu4KChBKc29uVHlwZXNNZXNzYWdlEi4KCmJvb2xfZmllbGQYASABKAhSGmJvb2xlYW5GaWVsZFdpdGhDdXN0b21OYW1lEhQKDGRvdWJsZV9maWVsZBgCIAEoARITCgtieXRlc19maWVsZBgDIAEoDBITCgtpbnQ2NF9maWVsZBgEIAEoAxImCgplbnVtX2ZpZWxkGAUgASgOMhIuc3BlYy5Kc29uVHlwZUVudW0SLQoNbWVzc2FnZV9maWVsZBgGIAEoCzIWLnNwZWMuSnNvblR5cGVzTWVzc2FnZRInCglhbnlfZmllbGQYByABKAsyFC5nb29nbGUucHJvdG9idWYuQW55EjEKDmR1cmF0aW9uX2ZpZWxkGAggASgLMhkuZ29vZ2xlLnByb3RvYnVmLkR1cmF0aW9uEisKC2VtcHR5X2ZpZWxkGAkgASgLMhYuZ29vZ2xlLnByb3RvYnVmLkVtcHR5EjQKEGZpZWxkX21hc2tfZmllbGQYCiABKAsyGi5nb29nbGUucHJvdG9idWYuRmllbGRNYXNrEi0KDHN0cnVjdF9maWVsZBgLIAEoCzIXLmdvb2dsZS5wcm90b2J1Zi5TdHJ1Y3QSKwoLdmFsdWVfZmllbGQYDCABKAsyFi5nb29nbGUucHJvdG9idWYuVmFsdWUSNAoQbGlzdF92YWx1ZV9maWVsZBgNIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5MaXN0VmFsdWUSNAoQbnVsbF92YWx1ZV9maWVsZBgOIAEoDjIaLmdvb2dsZS5wcm90b2J1Zi5O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VtOgI4ASpdCgxKc29uVHlwZUVudW0SHgoaSlNPTl9UWVBFX0VOVU1fVU5TUEVDSUZJRUQQABIWChJKU09OX1RZUEVfRU5VTV9ZRVMQARIVChFKU09OX1RZUEVfRU5VTV9OTxACYgZwcm90bzM", [file_google_protobuf_any, file_google_protobuf_duration, file_google_protobuf_empty, file_google_protobuf_field_mask, file_google_protobuf_struct, file_google_protobuf_timestamp, file_google_protobuf_wrappers]); + fileDesc("ChZleHRyYS9qc29uX3R5cGVzLnByb3RvEgRzcGVjIoYNChBKc29uVHlwZXNNZXNzYWdlEi4KCmJvb2xfZmllbGQYASABKAhSGmJvb2xlYW5GaWVsZFdpdGhDdXN0b21OYW1lEhQKDGRvdWJsZV9maWVsZBgCIAEoARITCgtieXRlc19maWVsZBgDIAEoDBITCgtpbnQ2NF9maWVsZBgEIAEoAxImCgplbnVtX2ZpZWxkGAUgASgOMhIuc3BlYy5Kc29uVHlwZUVudW0SLQoNbWVzc2FnZV9maWVsZBgGIAEoCzIWLnNwZWMuSnNvblR5cGVzTWVzc2FnZRInCglhbnlfZmllbGQYByABKAsyFC5nb29nbGUucHJvdG9idWYuQW55EjEKDmR1cmF0aW9uX2ZpZWxkGAggASgLMhkuZ29vZ2xlLnByb3RvYnVmLkR1cmF0aW9uEisKC2VtcHR5X2ZpZWxkGAkgASgLMhYuZ29vZ2xlLnByb3RvYnVmLkVtcHR5EjQKEGZpZWxkX21hc2tfZmllbGQYCiABKAsyGi5nb29nbGUucHJvdG9idWYuRmllbGRNYXNrEi0KDHN0cnVjdF9maWVsZBgLIAEoCzIXLmdvb2dsZS5wcm90b2J1Zi5TdHJ1Y3QSKwoLdmFsdWVfZmllbGQYDCABKAsyFi5nb29nbGUucHJvdG9idWYuVmFsdWUSNAoQbGlzdF92YWx1ZV9maWVsZBgNIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5MaXN0VmFsdWUSNAoQbnVsbF92YWx1ZV9maWVsZBgOIAEoDjIaLmdvb2dsZS5wcm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Nvbl9uYW1lX2h5cGhlbhgdIAEoCFIHZm9vLWJhchIoChpqc29uX25hbWVfc3RhcnRfd2l0aF9kaWdpdBgeIAEoCFIEMWZvbxIgCg9qc29uX25hbWVfc3BhY2UYHyABKAhSB2ZvbyBiYXISHgoNanNvbl9uYW1lX3RhYhggIAEoCFIHZm9vCWJhchIjChNqc29uX25hbWVfbm9uX2FzY2lpGCEgASgIUgbkvaDlpb0SIwoQanNvbl9uYW1lX2VzY2FwZRgiIAEoCFIJZm9vCmJhclxuGksKFU1hcEJvb2xFbnVtRmllbGRFbnRyeRILCgNrZXkYASABKAgSIQoFdmFsdWUYAiABKA4yEi5zcGVjLkpzb25UeXBlRW51bToCOAEqXQoMSnNvblR5cGVFbnVtEh4KGkpTT05fVFlQRV9FTlVNX1VOU1BFQ0lGSUVEEAASFgoSSlNPTl9UWVBFX0VOVU1fWUVTEAESFQoRSlNPTl9UWVBFX0VOVU1fTk8QAmIGcHJvdG8z", [file_google_protobuf_any, file_google_protobuf_duration, file_google_protobuf_empty, file_google_protobuf_field_mask, file_google_protobuf_struct, file_google_protobuf_timestamp, file_google_protobuf_wrappers]); /** * Describes the message spec.JsonTypesMessage. diff --git a/packages/protobuf-test/src/gen/ts,json_types/extra/json_types_pb.ts b/packages/protobuf-test/src/gen/ts,json_types/extra/json_types_pb.ts index 55e7b8d54..0a0c3a975 100644 --- a/packages/protobuf-test/src/gen/ts,json_types/extra/json_types_pb.ts +++ b/packages/protobuf-test/src/gen/ts,json_types/extra/json_types_pb.ts @@ -26,7 +26,7 @@ import type { JsonObject, Message } from "@bufbuild/protobuf"; * Describes the file extra/json_types.proto. */ export const file_extra_json_types: GenFile = /*@__PURE__*/ - fileDesc("ChZleHRyYS9qc29uX3R5cGVzLnByb3RvEgRzcGVjIu4KChBKc29uVHlwZXNNZXNzYWdlEi4KCmJvb2xfZmllbGQYASABKAhSGmJvb2xlYW5GaWVsZFdpdGhDdXN0b21OYW1lEhQKDGRvdWJsZV9maWVsZBgCIA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vYnVmLlVJbnQ2NFZhbHVlEjgKE3dyYXBwZWRfaW50MzJfZmllbGQYFCABKAsyGy5nb29nbGUucHJvdG9idWYuSW50MzJWYWx1ZRI6ChR3cmFwcGVkX3VpbnQzMl9maWVsZBgVIAEoCzIcLmdvb2dsZS5wcm90b2J1Zi5VSW50MzJWYWx1ZRI2ChJ3cmFwcGVkX2Jvb2xfZmllbGQYFiABKAsyGi5nb29nbGUucHJvdG9idWYuQm9vbFZhbHVlEjoKFHdyYXBwZWRfc3RyaW5nX2ZpZWxkGBcgASgLMhwuZ29vZ2xlLnByb3RvYnVmLlN0cmluZ1ZhbHVlEjgKE3dyYXBwZWRfYnl0ZXNfZmllbGQYGCABKAsyGy5nb29nbGUucHJvdG9idWYuQnl0ZXNWYWx1ZRIvChNyZXBlYXRlZF9lbnVtX2ZpZWxkGBkgAygOMhIuc3BlYy5Kc29uVHlwZUVudW0SSQoTbWFwX2Jvb2xfZW51bV9maWVsZBgaIAMoCzIsLnNwZWMuSnNvblR5cGVzTWVzc2FnZS5NYXBCb29sRW51bUZpZWxkRW50cnkaSwoVTWFwQm9vbEVudW1GaWVsZEVudHJ5EgsKA2tleRgBIAEoCBIhCgV2YWx1ZRgCIAEoDjISLnNwZWMuSnNvblR5cGVFbnVtOgI4ASpdCgxKc29uVHlwZUVudW0SHgoaSlNPTl9UWVBFX0VOVU1fVU5TUEVDSUZJRUQQABIWChJKU09OX1RZUEVfRU5VTV9ZRVMQARIVChFKU09OX1RZUEVfRU5VTV9OTxACYgZwcm90bzM", [file_google_protobuf_any, file_google_protobuf_duration, file_google_protobuf_empty, file_google_protobuf_field_mask, file_google_protobuf_struct, file_google_protobuf_timestamp, file_google_protobuf_wrappers]); + fileDesc("ChZleHRyYS9qc29uX3R5cGVzLnByb3RvEgRzcGVjIoYNChBKc29uVHlwZXNNZXNzYWdlEi4KCmJvb2xfZmllbGQYASABKAhSGmJvb2xlYW5GaWVsZFdpdGhDdXN0b21OYW1lEhQKDGRvdWJsZV9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GVFbnVtEh4KGkpTT05fVFlQRV9FTlVNX1VOU1BFQ0lGSUVEEAASFgoSSlNPTl9UWVBFX0VOVU1fWUVTEAESFQoRSlNPTl9UWVBFX0VOVU1fTk8QAmIGcHJvdG8z", [file_google_protobuf_any, file_google_protobuf_duration, file_google_protobuf_empty, file_google_protobuf_field_mask, file_google_protobuf_struct, file_google_protobuf_timestamp, file_google_protobuf_wrappers]); /** * @generated from message spec.JsonTypesMessage @@ -161,6 +161,47 @@ export type JsonTypesMessage = Message<"spec.JsonTypesMessage"> & { * @generated from field: map map_bool_enum_field = 26; */ mapBoolEnumField: { [key: string]: JsonTypeEnum }; + + /** + * @generated from field: bool json_name_ok = 27 [json_name = "Foo123_bar$"]; + */ + jsonNameOk: boolean; + + /** + * @generated from field: bool json_name_at = 28 [json_name = "foo@"]; + */ + jsonNameAt: boolean; + + /** + * @generated from field: bool json_name_hyphen = 29 [json_name = "foo-bar"]; + */ + jsonNameHyphen: boolean; + + /** + * @generated from field: bool json_name_start_with_digit = 30 [json_name = "1foo"]; + */ + jsonNameStartWithDigit: boolean; + + /** + * @generated from field: bool json_name_space = 31 [json_name = "foo bar"]; + */ + jsonNameSpace: boolean; + + /** + * @generated from field: bool json_name_tab = 32 [json_name = "foo bar"]; + */ + jsonNameTab: boolean; + + /** + * @generated from field: bool json_name_non_ascii = 33 [json_name = "你好"]; + */ + jsonNameNonAscii: boolean; + + /** + * @generated from field: bool json_name_escape = 34 [json_name = "foo + * bar\n"]; + */ + jsonNameEscape: boolean; }; /** @@ -296,6 +337,47 @@ export type JsonTypesMessageJson = { * @generated from field: map map_bool_enum_field = 26; */ mapBoolEnumField?: { [key: string]: JsonTypeEnumJson }; + + /** + * @generated from field: bool json_name_ok = 27 [json_name = "Foo123_bar$"]; + */ + Foo123_bar$?: boolean; + + /** + * @generated from field: bool json_name_at = 28 [json_name = "foo@"]; + */ + "foo@"?: boolean; + + /** + * @generated from field: bool json_name_hyphen = 29 [json_name = "foo-bar"]; + */ + "foo-bar"?: boolean; + + /** + * @generated from field: bool json_name_start_with_digit = 30 [json_name = "1foo"]; + */ + "1foo"?: boolean; + + /** + * @generated from field: bool json_name_space = 31 [json_name = "foo bar"]; + */ + "foo bar"?: boolean; + + /** + * @generated from field: bool json_name_tab = 32 [json_name = "foo bar"]; + */ + "foo bar"?: boolean; + + /** + * @generated from field: bool json_name_non_ascii = 33 [json_name = "你好"]; + */ + "你好"?: boolean; + + /** + * @generated from field: bool json_name_escape = 34 [json_name = "foo + * bar\n"]; + */ + "foo\nbar\\n"?: boolean; }; /** diff --git a/packages/protobuf-test/src/gen/ts/extra/json_types_pb.ts b/packages/protobuf-test/src/gen/ts/extra/json_types_pb.ts index ff6d882d0..590910619 100644 --- a/packages/protobuf-test/src/gen/ts/extra/json_types_pb.ts +++ b/packages/protobuf-test/src/gen/ts/extra/json_types_pb.ts @@ -26,7 +26,7 @@ import type { JsonObject, Message } from "@bufbuild/protobuf"; * Describes the file extra/json_types.proto. */ export const file_extra_json_types: GenFile = /*@__PURE__*/ - fileDesc("ChZleHRyYS9qc29uX3R5cGVzLnByb3RvEgRzcGVjIu4KChBKc29uVHlwZXNNZXNzYWdlEi4KCmJvb2xfZmllbGQYASABKAhSGmJvb2xlYW5GaWVsZFdpdGhDdXN0b21OYW1lEhQKDGRvdWJsZV9maWVsZBgCIAEoARITCgtieXRlc19maWVsZBgDIAEoDBITCgtpbnQ2NF9maWVsZBgEIAEoAxImCgplbnVtX2ZpZWxkGAUgASgOMhIuc3BlYy5Kc29uVHlwZUVudW0SLQoNbWVzc2FnZV9maWVsZBgGIAEoCzIWLnNwZWMuSnNvblR5cGVzTWVzc2FnZRInCglhbnlfZmllbGQYByABKAsyFC5nb29nbGUucHJvdG9idWYuQW55EjEKDmR1cmF0aW9uX2ZpZWxkGAggASgLMhkuZ29vZ2xlLnByb3RvYnVmLkR1cmF0aW9uEisKC2VtcHR5X2ZpZWxkGAkgASgLMhYuZ29vZ2xlLnByb3RvYnVmLkVtcHR5EjQ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RfYnl0ZXNfZmllbGQYGCABKAsyGy5nb29nbGUucHJvdG9idWYuQnl0ZXNWYWx1ZRIvChNyZXBlYXRlZF9lbnVtX2ZpZWxkGBkgAygOMhIuc3BlYy5Kc29uVHlwZUVudW0SSQoTbWFwX2Jvb2xfZW51bV9maWVsZBgaIAMoCzIsLnNwZWMuSnNvblR5cGVzTWVzc2FnZS5NYXBCb29sRW51bUZpZWxkRW50cnkaSwoVTWFwQm9vbEVudW1GaWVsZEVudHJ5EgsKA2tleRgBIAEoCBIhCgV2YWx1ZRgCIAEoDjISLnNwZWMuSnNvblR5cGVFbnVtOgI4ASpdCgxKc29uVHlwZUVudW0SHgoaSlNPTl9UWVBFX0VOVU1fVU5TUEVDSUZJRUQQABIWChJKU09OX1RZUEVfRU5VTV9ZRVMQARIVChFKU09OX1RZUEVfRU5VTV9OTxACYgZwcm90bzM", [file_google_protobuf_any, file_google_protobuf_duration, file_google_protobuf_empty, file_google_protobuf_field_mask, file_google_protobuf_struct, file_google_protobuf_timestamp, file_google_protobuf_wrappers]); + fileDesc("ChZleHRyYS9qc29uX3R5cGVzLnByb3RvEgRzcGVjIoYNChBKc29uVHlwZXNNZXNzYWdlEi4KCmJvb2xfZmllbGQYASABKAhSGmJvb2xlYW5GaWVsZFdpdGhDdXN0b21OYW1lEhQKDGRvdWJsZV9maWVsZBgCIAEoARITCgtieXRlc19maWVsZBgDIAEoDBITCgtpbnQ2NF9maWVsZBgEIAEoAxImCgplbnVtX2ZpZWxkGAUgASgOMhIuc3BlYy5Kc29uVHlwZUVudW0SLQoNbWVzc2FnZV9maWVsZBgGIAEoCzIWLnNwZWMuSnNvblR5cGVzTWVzc2FnZRInCglhbnlfZmllbGQYByABKAsyFC5nb29nbGUucHJvdG9idWYuQW55EjEKDmR1cmF0aW9uX2ZpZWxkGAggASgLMhkuZ29vZ2xlLnByb3RvYnVmLkR1cmF0aW9uEisKC2VtcHR5X2ZpZWxkGAkgASgLMhYuZ29vZ2xlLnByb3RvYnVmL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E3dyYXBwZWRfYnl0ZXNfZmllbGQYGCABKAsyGy5nb29nbGUucHJvdG9idWYuQnl0ZXNWYWx1ZRIvChNyZXBlYXRlZF9lbnVtX2ZpZWxkGBkgAygOMhIuc3BlYy5Kc29uVHlwZUVudW0SSQoTbWFwX2Jvb2xfZW51bV9maWVsZBgaIAMoCzIsLnNwZWMuSnNvblR5cGVzTWVzc2FnZS5NYXBCb29sRW51bUZpZWxkRW50cnkSIQoManNvbl9uYW1lX29rGBsgASgIUgtGb28xMjNfYmFyJBIaCgxqc29uX25hbWVfYXQYHCABKAhSBGZvb0ASIQoQanNvbl9uYW1lX2h5cGhlbhgdIAEoCFIHZm9vLWJhchIoChpqc29uX25hbWVfc3RhcnRfd2l0aF9kaWdpdBgeIAEoCFIEMWZvbxIgCg9qc29uX25hbWVfc3BhY2UYHyABKAhSB2ZvbyBiYXISHgoNanNvbl9uYW1lX3RhYhggIAEoCFIHZm9vCWJhchIjChNqc29uX25hbWVfbm9uX2FzY2lpGCEgASgIUgbkvaDlpb0SIwoQanNvbl9uYW1lX2VzY2FwZRgiIAEoCFIJZm9vCmJhclxuGksKFU1hcEJvb2xFbnVtRmllbGRFbnRyeRILCgNrZXkYASABKAgSIQoFdmFsdWUYAiABKA4yEi5zcGVjLkpzb25UeXBlRW51bToCOAEqXQoMSnNvblR5cGVFbnVtEh4KGkpTT05fVFlQRV9FTlVNX1VOU1BFQ0lGSUVEEAASFgoSSlNPTl9UWVBFX0VOVU1fWUVTEAESFQoRSlNPTl9UWVBFX0VOVU1fTk8QAmIGcHJvdG8z", [file_google_protobuf_any, file_google_protobuf_duration, file_google_protobuf_empty, file_google_protobuf_field_mask, file_google_protobuf_struct, file_google_protobuf_timestamp, file_google_protobuf_wrappers]); /** * @generated from message spec.JsonTypesMessage @@ -161,6 +161,47 @@ export type JsonTypesMessage = Message<"spec.JsonTypesMessage"> & { * @generated from field: map map_bool_enum_field = 26; */ mapBoolEnumField: { [key: string]: JsonTypeEnum }; + + /** + * @generated from field: bool json_name_ok = 27 [json_name = "Foo123_bar$"]; + */ + jsonNameOk: boolean; + + /** + * @generated from field: bool json_name_at = 28 [json_name = "foo@"]; + */ + jsonNameAt: boolean; + + /** + * @generated from field: bool json_name_hyphen = 29 [json_name = "foo-bar"]; + */ + jsonNameHyphen: boolean; + + /** + * @generated from field: bool json_name_start_with_digit = 30 [json_name = "1foo"]; + */ + jsonNameStartWithDigit: boolean; + + /** + * @generated from field: bool json_name_space = 31 [json_name = "foo bar"]; + */ + jsonNameSpace: boolean; + + /** + * @generated from field: bool json_name_tab = 32 [json_name = "foo bar"]; + */ + jsonNameTab: boolean; + + /** + * @generated from field: bool json_name_non_ascii = 33 [json_name = "你好"]; + */ + jsonNameNonAscii: boolean; + + /** + * @generated from field: bool json_name_escape = 34 [json_name = "foo + * bar\n"]; + */ + jsonNameEscape: boolean; }; /** diff --git a/packages/protobuf-test/src/generate-code.test.ts b/packages/protobuf-test/src/generate-code.test.ts index c9a67a62b..ed1be74f9 100644 --- a/packages/protobuf-test/src/generate-code.test.ts +++ b/packages/protobuf-test/src/generate-code.test.ts @@ -98,6 +98,14 @@ test("source retention options are unavailable in generated code", () => { describe("JSON types", () => { const ok_ts: json_types_ts_json.JsonTypesMessageJson = { booleanFieldWithCustomName: true, + Foo123_bar$: true, + "foo@": true, + "foo-bar": true, + "1foo": true, + "foo bar": true, + "foo\tbar": true, + 你好: true, + "foo\nbar\\n": true, doubleField: "Infinity", bytesField: "aGVsbG8gd29ybGQ=", int64Field: "123", @@ -110,6 +118,14 @@ describe("JSON types", () => { expect(ok_ts).toBeDefined(); const ok_js: json_types_js_json.JsonTypesMessageJson = { booleanFieldWithCustomName: true, + Foo123_bar$: true, + "foo@": true, + "foo-bar": true, + "1foo": true, + "foo bar": true, + "foo\tbar": true, + 你好: true, + "foo\nbar\\n": true, doubleField: "Infinity", bytesField: "aGVsbG8gd29ybGQ=", int64Field: "123", diff --git a/packages/protoc-gen-es/src/protoc-gen-es-plugin.ts b/packages/protoc-gen-es/src/protoc-gen-es-plugin.ts index 9ccb66e0a..de638e31e 100644 --- a/packages/protoc-gen-es/src/protoc-gen-es-plugin.ts +++ b/packages/protoc-gen-es/src/protoc-gen-es-plugin.ts @@ -472,19 +472,16 @@ function generateMessageJsonShape(f: GeneratedFile, message: DescMessage, target } else { f.print(exp, " = {"); for (const field of message.fields) { - switch (field.kind) { - default: - f.print(f.jsDoc(field, " ")); - // eslint-disable-next-line no-case-declarations - let jsonName: Printable = field.jsonName; - if (jsonName === "" - || /^[0-9]/.test(jsonName) - || jsonName.indexOf("@") > -1) { - jsonName = f.string(jsonName); - } - f.print(" ", jsonName, "?: ", fieldJsonType(field), ";"); - break; + f.print(f.jsDoc(field, " ")); + let jsonName: Printable = field.jsonName; + const startWithNumber = /^[0-9]/; + const containsSpecialChar = /[^a-zA-Z0-9_$]/; + if (jsonName === "" + || startWithNumber.test(jsonName) + || containsSpecialChar.test(jsonName)) { + jsonName = f.string(jsonName); } + f.print(" ", jsonName, "?: ", fieldJsonType(field), ";"); if (message.fields.indexOf(field) < message.fields.length - 1) { f.print(); }