Valid reports whether data is a valid JSON encoding.
package main import ( "encoding/json" "fmt" ) func main() { goodJSON := `{"example": 1}` badJSON := `{"example":2:]}}` fmt.Println(json.Valid([]byte(goodJSON)), json.Valid([]byte(badJSON))) }