json-parse-object-edge-cases.js (1349B)
1 // Array includes objects with duplicate keys and integer keys. 2 let json = `[ 3 {"x1": 1}, 4 {"x2": 2}, 5 {"x3": 3}, 6 {"x1": 1, "y": 0}, 7 {"x2": 1, "y": 0}, 8 {"x3": 1, "y": 0}, 9 {"x1": 1, "x1": 2, "y": 0}, 10 {"x1": 1, "x1": 2, "y": 0}, 11 {"x1": 1, "x1": 2, "y": 0}, 12 {"0": 1, "x1": 1}, 13 {"0": 1, "0": 2, "x1": 1}, 14 {"0": 1, "0": 2, "x1": 1}, 15 {"2147483648": 1}, 16 {"2147483648": 2}, 17 {"2147483648": 0, "x": 0, "2147483648": 3}, 18 {"4294967295": 4}, 19 {"4294967295": 5}, 20 {"-1": 6}, 21 {"-1": 7}, 22 {"__proto__": 1}, 23 {"__proto__": 2} 24 ]`; 25 for (let i = 0; i < 3; i++) { 26 let res = JSON.parse(json); 27 assertEq(JSON.stringify(res), 28 `[{"x1":1},` + 29 `{"x2":2},` + 30 `{"x3":3},` + 31 `{"x1":1,"y":0},` + 32 `{"x2":1,"y":0},` + 33 `{"x3":1,"y":0},` + 34 `{"x1":2,"y":0},` + 35 `{"x1":2,"y":0},` + 36 `{"x1":2,"y":0},` + 37 `{"0":1,"x1":1},` + 38 `{"0":2,"x1":1},` + 39 `{"0":2,"x1":1},` + 40 `{"2147483648":1},` + 41 `{"2147483648":2},` + 42 `{"2147483648":3,"x":0},` + 43 `{"4294967295":4},` + 44 `{"4294967295":5},` + 45 `{"-1":6},` + 46 `{"-1":7},` + 47 `{"__proto__":1},` + 48 `{"__proto__":2}]`); 49 }