For anyone else looking for a way to validate any JSON string regardless of schema, try the following:
func IsJSON(str string) bool {
var js json.RawMessage
return json.Unmarshal([]byte(str), &js) == nil
}
For anyone else looking for a way to validate any JSON string regardless of schema, try the following:
func IsJSON(str string) bool {
var js json.RawMessage
return json.Unmarshal([]byte(str), &js) == nil
}