(value)
| 1726 | |
| 1727 | // Internal: Parses a JSON `value` token. |
| 1728 | var get = function (value) { |
| 1729 | var results, hasMembers; |
| 1730 | if (value == "$") { |
| 1731 | // Unexpected end of input. |
| 1732 | abort(); |
| 1733 | } |
| 1734 | if (typeof value == "string") { |
| 1735 | if ((charIndexBuggy ? value.charAt(0) : value[0]) == "@") { |
| 1736 | // Remove the sentinel `@` character. |
| 1737 | return value.slice(1); |
| 1738 | } |
| 1739 | // Parse object and array literals. |
| 1740 | if (value == "[") { |
| 1741 | // Parses a JSON array, returning a new JavaScript array. |
| 1742 | results = []; |
| 1743 | for (;; hasMembers || (hasMembers = true)) { |
| 1744 | value = lex(); |
| 1745 | // A closing square bracket marks the end of the array literal. |
| 1746 | if (value == "]") { |
| 1747 | break; |
| 1748 | } |
| 1749 | // If the array literal contains elements, the current token |
| 1750 | // should be a comma separating the previous element from the |
| 1751 | // next. |
| 1752 | if (hasMembers) { |
| 1753 | if (value == ",") { |
| 1754 | value = lex(); |
| 1755 | if (value == "]") { |
| 1756 | // Unexpected trailing `,` in array literal. |
| 1757 | abort(); |
| 1758 | } |
| 1759 | } else { |
| 1760 | // A `,` must separate each array element. |
| 1761 | abort(); |
| 1762 | } |
| 1763 | } |
| 1764 | // Elisions and leading commas are not permitted. |
| 1765 | if (value == ",") { |
| 1766 | abort(); |
| 1767 | } |
| 1768 | results.push(get(value)); |
| 1769 | } |
| 1770 | return results; |
| 1771 | } else if (value == "{") { |
| 1772 | // Parses a JSON object, returning a new JavaScript object. |
| 1773 | results = {}; |
| 1774 | for (;; hasMembers || (hasMembers = true)) { |
| 1775 | value = lex(); |
| 1776 | // A closing curly brace marks the end of the object literal. |
| 1777 | if (value == "}") { |
| 1778 | break; |
| 1779 | } |
| 1780 | // If the object literal contains members, the current token |
| 1781 | // should be a comma separator. |
| 1782 | if (hasMembers) { |
| 1783 | if (value == ",") { |
| 1784 | value = lex(); |
| 1785 | if (value == "}") { |
no test coverage detected