Files
opencloud/services/graph/pkg/service/v0/utils.go

14 lines
306 B
Go

package svc
import (
"encoding/json"
"io"
)
// StrictJSONUnmarshal is a wrapper around json.Unmarshal that returns an error if the json contains unknown fields.
func StrictJSONUnmarshal(r io.Reader, v interface{}) error {
dec := json.NewDecoder(r)
dec.DisallowUnknownFields()
return dec.Decode(v)
}