go-approval-tests icon indicating copy to clipboard operation
go-approval-tests copied to clipboard

VerifyJSONBytes requires `map[string]interface{}`

Open newhook opened this issue 2 years ago • 0 comments

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...)
	}
}

newhook avatar Jun 03 '22 13:06 newhook