MCPcopy
hub / github.com/loggerhead/json4u / genJSON

Function genJSON

__tests__/parse.test.ts:24–45  ·  view source on GitHub ↗
(maxDepth = 5)

Source from the content-addressed store, hash-verified

22}
23
24function genJSON(maxDepth = 5): any {
25 switch (random(0, 2)) {
26 case 0: {
27 const v: any = {};
28 for (let i = 0; i < random(0, 3); i++) {
29 v[`${i}`] = genJSON(maxDepth - 1);
30 }
31 return v;
32 }
33 case 1: {
34 const v = [];
35 for (let i = 0; i < random(0, 3); i++) {
36 v.push(genJSON(maxDepth - 1));
37 }
38 return v;
39 }
40 case 2: {
41 const vv = [0, "", true, false, null];
42 return vv[random(0, vv.length - 1)];
43 }
44 }
45}
46
47describe("parseJSON", () => {
48 test("error", () => {

Callers 1

parse.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected