Skip to content

Commit

Permalink
Merge pull request #5 from pcvolkmer/no_unknown
Browse files Browse the repository at this point in the history
feat: disallow unknown fields
  • Loading branch information
pcvolkmer authored Dec 25, 2024
2 parents f1837e6 + 551cf85 commit ea606cd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mtb.go
Original file line number Diff line number Diff line change
@@ -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
}

Expand Down

0 comments on commit ea606cd

Please sign in to comment.