A tiny Go module for lightweight JSON detection.
isjson.IsJSON([]byte) provides a fast heuristic to check whether a byte slice
looks like a JSON object. If it looks like JSON, it probably is - that's the
philosophy. Designed for speed over precision, it's ideal for scenarios where
making decisions on appearance is good enough.
- This is a heuristic, not a parser.
- It won't catch malformed JSON or deeply nested issues.
- Best used when performance matters and input is reasonably well-formed.
- Not suitable for strict validation or security-critical contexts.
package main
import (
"fmt"
"github.com/dbnski/isjson"
)
func main() {
good := []byte(`{"hello":"world"}`)
bad := []byte(`not json at all`)
fmt.Println("Good input:", isjson.IsJSON(good)) // true
fmt.Println("Bad input:", isjson.IsJSON(bad)) // false
}