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:
+2
-2
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user