How to remove @type or type_url after marshal google.protobuf.Any?
DouFuJuShi opened this issue · comments
What you're talking about is the proper JSON representation of the google.protobuf.Any
type: https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/any.proto#L101-L126. Perhaps you want to use something else?
What you're talking about is the proper JSON representation of the
google.protobuf.Any
type: https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/any.proto#L101-L126. Perhaps you want to use something else?
In order to return a unified response body, define a messge type and Custom Marshaler :
![image](https://private-user-images.githubusercontent.com/13195119/329436175-5e8ee183-def1-4696-93f9-2e5790987769.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkxOTE4OTQsIm5iZiI6MTcxOTE5MTU5NCwicGF0aCI6Ii8xMzE5NTExOS8zMjk0MzYxNzUtNWU4ZWUxODMtZGVmMS00Njk2LTkzZjktMmU1NzkwOTg3NzY5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI0VDAxMTMxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTMzN2M4Y2E2NTYzYjc0MzVjMjUyZTg0M2ZkZTBhOGQ1YWQ5MTM4MTAzZDllOWQxMjQxMmIwZDA3ZGI0MzRmMzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.fwzGwoJk5cl0POiRa7bX4329nF_FD5WVO8i6gdqM9YE)
Because of google.protobuf.Any
,The response json will have @type.
I want to remove @type, how can I do it ?
I see you have a custom marshaler already - you can control exactly what the format is right there.
I strongly suggest not using google.protobuf.Any for responses though. You're losing many of the benefits of protobuf.
I'm going to close this as this is not a support forum for Go and there's nothing the gateway can do about this.