1
0
mirror of https://github.com/dnpm-dip/mv64e-mtb-dto-go.git synced 2025-07-01 18:32:55 +00:00

feat: disallow unknown fields

This commit is contained in:
2024-12-25 01:32:43 +01:00
parent f1837e6c91
commit 551cf85060

9
mtb.go
View File

@ -1,10 +1,15 @@
package mtb
import "encoding/json"
import (
"bytes"
"encoding/json"
)
func UnmarshalMtb(data []byte) (Mtb, error) {
var r Mtb
err := json.Unmarshal(data, &r)
dec := json.NewDecoder(bytes.NewReader(data))
dec.DisallowUnknownFields()
err := dec.Decode(&r)
return r, err
}