| 414 | }, |
| 415 | |
| 416 | object = function () { |
| 417 | |
| 418 | // Parse an object value. |
| 419 | |
| 420 | var key, |
| 421 | object = {}; |
| 422 | |
| 423 | if (ch === '{') { |
| 424 | next('{'); |
| 425 | white(); |
| 426 | while (ch) { |
| 427 | if (ch === '}') { |
| 428 | next('}'); |
| 429 | return object; // Potentially empty object |
| 430 | } |
| 431 | |
| 432 | // Keys can be unquoted. If they are, they need to be |
| 433 | // valid JS identifiers. |
| 434 | if (ch === '"' || ch === "'") { |
| 435 | key = string(); |
| 436 | } else { |
| 437 | key = identifier(); |
| 438 | } |
| 439 | |
| 440 | white(); |
| 441 | next(':'); |
| 442 | object[key] = value(); |
| 443 | white(); |
| 444 | // If there's no comma after this pair, this needs to be |
| 445 | // the end of the object. |
| 446 | if (ch !== ',') { |
| 447 | next('}'); |
| 448 | return object; |
| 449 | } |
| 450 | next(','); |
| 451 | white(); |
| 452 | } |
| 453 | } |
| 454 | error("Bad object"); |
| 455 | }; |
| 456 | |
| 457 | value = function () { |
| 458 | |