(value)
| 762 | |
| 763 | // Internal: Parses a JSON `value` token. |
| 764 | var get = function (value) { |
| 765 | var results, hasMembers; |
| 766 | if (value == "$") { |
| 767 | // Unexpected end of input. |
| 768 | abort(); |
| 769 | } |
| 770 | if (typeof value == "string") { |
| 771 | if ((charIndexBuggy ? value.charAt(0) : value[0]) == "@") { |
| 772 | // Remove the sentinel `@` character. |
| 773 | return value.slice(1); |
| 774 | } |
| 775 | // Parse object and array literals. |
| 776 | if (value == "[") { |
| 777 | // Parses a JSON array, returning a new JavaScript array. |
| 778 | results = []; |
| 779 | for (;;) { |
| 780 | value = lex(); |
| 781 | // A closing square bracket marks the end of the array literal. |
| 782 | if (value == "]") { |
| 783 | break; |
| 784 | } |
| 785 | // If the array literal contains elements, the current token |
| 786 | // should be a comma separating the previous element from the |
| 787 | // next. |
| 788 | if (hasMembers) { |
| 789 | if (value == ",") { |
| 790 | value = lex(); |
| 791 | if (value == "]") { |
| 792 | // Unexpected trailing `,` in array literal. |
| 793 | abort(); |
| 794 | } |
| 795 | } else { |
| 796 | // A `,` must separate each array element. |
| 797 | abort(); |
| 798 | } |
| 799 | } else { |
| 800 | hasMembers = true; |
| 801 | } |
| 802 | // Elisions and leading commas are not permitted. |
| 803 | if (value == ",") { |
| 804 | abort(); |
| 805 | } |
| 806 | results.push(get(value)); |
| 807 | } |
| 808 | return results; |
| 809 | } else if (value == "{") { |
| 810 | // Parses a JSON object, returning a new JavaScript object. |
| 811 | results = {}; |
| 812 | for (;;) { |
| 813 | value = lex(); |
| 814 | // A closing curly brace marks the end of the object literal. |
| 815 | if (value == "}") { |
| 816 | break; |
| 817 | } |
| 818 | // If the object literal contains members, the current token |
| 819 | // should be a comma separator. |
| 820 | if (hasMembers) { |
| 821 | if (value == ",") { |
no test coverage detected