From 551cf8506072a9c7f309addd3bc726143fbf5993 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Wed, 25 Dec 2024 01:32:43 +0100 Subject: [PATCH] feat: disallow unknown fields --- mtb.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mtb.go b/mtb.go index 0697716..c623924 100644 --- a/mtb.go +++ b/mtb.go @@ -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 }