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

Function genObject

json_fuzz_test.go:205–217  ·  view source on GitHub ↗

genObject emits an object with 0–5 entries. Keys are drawn from a set that includes the dangerous cases: empty-string "", unicode (\uXXXX), long, and escaped special characters.

(r *rand.Rand, depth int, buf *[]byte)

Source from the content-addressed store, hash-verified

203// that includes the dangerous cases: empty-string "", unicode (\uXXXX),
204// long, and escaped special characters.
205func genObject(r *rand.Rand, depth int, buf *[]byte) {
206 *buf = append(*buf, '{')
207 n := r.Intn(6) // 0..5 entries
208 for i := 0; i < n; i++ {
209 if i > 0 {
210 *buf = append(*buf, ',')
211 }
212 genKey(r, buf)
213 *buf = append(*buf, ':')
214 genValue(r, depth+1, buf)
215 }
216 *buf = append(*buf, '}')
217}
218
219// genArray emits an array with 0–5 elements (including the empty array []).
220func genArray(r *rand.Rand, depth int, buf *[]byte) {

Callers 1

genValueFunction · 0.85

Calls 2

genKeyFunction · 0.85
genValueFunction · 0.85

Tested by

no test coverage detected