1
0
mirror of https://github.com/go-kratos/kratos.git synced 2026-05-16 09:48:28 +02:00

fix proto options (#804)

This commit is contained in:
Tony Chen
2021-03-29 00:00:48 +08:00
committed by GitHub
parent 1ee3225155
commit a0fe496a91
+2 -2
View File
@@ -110,14 +110,14 @@ func convertMap(src interface{}) interface{} {
func marshalJSON(v interface{}) ([]byte, error) {
if m, ok := v.(proto.Message); ok {
return protojson.Marshal(m)
return protojson.MarshalOptions{EmitUnpopulated: true}.Marshal(m)
}
return json.Marshal(v)
}
func unmarshalJSON(data []byte, v interface{}) error {
if m, ok := v.(proto.Message); ok {
return protojson.Unmarshal(data, m)
return protojson.UnmarshalOptions{DiscardUnknown: true}.Unmarshal(data, m)
}
return json.Unmarshal(data, v)
}