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

Function genJSON

json_fuzz_test.go:156–160  ·  view source on GitHub ↗

genJSON returns a valid JSON document generated from the grammar. The output is always valid JSON per RFC 8259 (the corpus-sanity test asserts json.Valid on every generated document). Depth controls recursion: at depth >= maxGenDepth the generator emits only scalars to bound the output size and str

(r *rand.Rand, depth int)

Source from the content-addressed store, hash-verified

154// Depth controls recursion: at depth >= maxGenDepth the generator emits
155// only scalars to bound the output size and stress the base cases.
156func genJSON(r *rand.Rand, depth int) []byte {
157 var buf []byte
158 genValue(r, depth, &buf)
159 return buf
160}
161
162// genValue appends one JSON value to buf, chosen from a weighted
163// distribution that favors containers at shallow depth (to exercise

Callers 4

FuzzJSONStructureAwareFunction · 0.85
TestJSONFuzzCorpusSanityFunction · 0.85
FuzzEncodingJSONFunction · 0.85

Calls 1

genValueFunction · 0.85

Tested by

no test coverage detected