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.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTU3MDU1MzUsIm5iZiI6MTcxNTcwNTIzNSwicGF0aCI6Ii8xMzE5NTExOS8zMjk0MzYxNzUtNWU4ZWUxODMtZGVmMS00Njk2LTkzZjktMmU1NzkwOTg3NzY5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA1MTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNTE0VDE2NDcxNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWUzMjBhMTVmZWM3ODUwOTQzMzEwYWNjMzRlMjlmY2RiMGJmZWQ2NDAyZDA2NTdhN2FkYzAzNTcxNGQzNGRiMjEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.jjju6C2j6HoMQAHBx5ig_VEh7kzdztIzMmgbz-ElRGc)
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.