go-approval-tests
go-approval-tests copied to clipboard
VerifyJSONBytes requires `map[string]interface{}`
Why does this require the object demarshal to a map[string]interface{}
? The bytes could equally well contain any valid json (arrays, strings, and so on).
t.Helper()
var obj map[string]interface{}
err := json.Unmarshal(bs, &obj)
if err != nil {
message := fmt.Sprintf("error while parsing JSON\nerror:\n %s\nJSON:\n %s\n", err, string(bs))
Verify(t, strings.NewReader(message), alwaysOption(opts).WithExtension(".json"))
} else {
VerifyJSONStruct(t, obj, opts...)
}
}