MCPcopy Create free account
hub / github.com/buger/jsonparser / looksLikeJSON

Function looksLikeJSON

json_fuzz_test.go:1480–1493  ·  view source on GitHub ↗

============================================================================= The fuzzer (testing.F, native go-fuzz) ============================================================================= looksLikeJSON reports whether data begins with a byte that could start a JSON value. This is a cheap pre-

(data []byte)

Source from the content-addressed store, hash-verified

1478// or to regenerate from the grammar (to maintain structural coverage when
1479// the engine has mutated the data into non-JSON garbage).
1480func looksLikeJSON(data []byte) bool {
1481 for _, b := range data {
1482 switch b {
1483 case ' ', '\t', '\n', '\r':
1484 continue
1485 case '{', '[', '"', 't', 'f', 'n', '-',
1486 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
1487 return true
1488 default:
1489 return false
1490 }
1491 }
1492 return false
1493}
1494
1495// FuzzJSONStructureAware is the structure-aware fuzzer. It combines:
1496// - Grammar-based JSON generation (always emits valid structures).

Callers 2

FuzzJSONStructureAwareFunction · 0.85
FuzzEncodingJSONFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected