| 379 | value, // Place holder for the value function. |
| 380 | |
| 381 | array = function () { |
| 382 | |
| 383 | // Parse an array value. |
| 384 | |
| 385 | var array = []; |
| 386 | |
| 387 | if (ch === '[') { |
| 388 | next('['); |
| 389 | white(); |
| 390 | while (ch) { |
| 391 | if (ch === ']') { |
| 392 | next(']'); |
| 393 | return array; // Potentially empty array |
| 394 | } |
| 395 | // ES5 allows omitting elements in arrays, e.g. [,] and |
| 396 | // [,null]. We don't allow this in JSON5. |
| 397 | if (ch === ',') { |
| 398 | error("Missing array element"); |
| 399 | } else { |
| 400 | array.push(value()); |
| 401 | } |
| 402 | white(); |
| 403 | // If there's no comma after this value, this needs to |
| 404 | // be the end of the array. |
| 405 | if (ch !== ',') { |
| 406 | next(']'); |
| 407 | return array; |
| 408 | } |
| 409 | next(','); |
| 410 | white(); |
| 411 | } |
| 412 | } |
| 413 | error("Bad array"); |
| 414 | }, |
| 415 | |
| 416 | object = function () { |
| 417 | |