mirror of
https://github.com/go-kratos/kratos.git
synced 2025-03-17 21:07:54 +02:00
fix proto options (#804)
This commit is contained in:
parent
1ee3225155
commit
a0fe496a91
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user