| 726 | } |
| 727 | |
| 728 | @Test |
| 729 | public void testObject() throws IOException { |
| 730 | parse("{}", "{}"); |
| 731 | parse("{}", "{}"); |
| 732 | parse(" \r\n\t{\r\t\n }\r\n\t ", "{}"); |
| 733 | |
| 734 | parse("{'':null}", "{s0}"); |
| 735 | |
| 736 | err("}"); |
| 737 | err("[}]"); |
| 738 | err("{"); |
| 739 | err("[{]"); |
| 740 | err("{{}"); |
| 741 | err("[{{}]"); |
| 742 | err("{}}"); |
| 743 | err("[{}}]"); |
| 744 | err("{1}"); |
| 745 | err("[{1}]"); |
| 746 | err("{'a'}"); |
| 747 | err("{'a','b'}"); |
| 748 | err("{[]:'b'}"); |
| 749 | err("{{'a':'b'}:'c'}"); |
| 750 | err("{'a','b'}}"); |
| 751 | |
| 752 | // bare strings allow these to pass |
| 753 | flags = JSONParser.FLAGS_STRICT; |
| 754 | err("{null:'b'}"); |
| 755 | err("{true:'b'}"); |
| 756 | err("{false:'b'}"); |
| 757 | err("{,}"); // test that extra commas fail |
| 758 | err("{{},}"); |
| 759 | err("{'a':'b',}"); |
| 760 | flags = JSONParser.FLAGS_DEFAULT; |
| 761 | |
| 762 | parse("{}", new Object[] {m, M, e}); |
| 763 | parse("{,}", new Object[] {m, M, e}); |
| 764 | parse("{,,}", new Object[] {m, M, e}); |
| 765 | parse("{'a':{},}", new Object[] {m, "a", m, M, M, e}); |
| 766 | parse("{'a':{},,}", new Object[] {m, "a", m, M, M, e}); |
| 767 | parse("{,'a':{,},,}", new Object[] {m, "a", m, M, M, e}); |
| 768 | parse("{'a':'b'}", new Object[] {m, "a", "b", M, e}); |
| 769 | parse("{'a':5}", new Object[] {m, "a", o(5), M, e}); |
| 770 | parse("{'a':null}", new Object[] {m, "a", N, M, e}); |
| 771 | parse("{'a':[]}", new Object[] {m, "a", a, A, M, e}); |
| 772 | parse("{'a':{'b':'c'}}", new Object[] {m, "a", m, "b", "c", M, M, e}); |
| 773 | |
| 774 | String big = "Now is the time for all good men to come to the aid of their country!"; |
| 775 | String bigger = big + big + big + big + big; |
| 776 | parse( |
| 777 | "{'" + bigger + "':'" + bigger + "','a':'b'}", |
| 778 | new Object[] {m, bigger, bigger, "a", "b", M, e}); |
| 779 | |
| 780 | flags = JSONParser.ALLOW_UNQUOTED_KEYS; |
| 781 | parse("{a:'b'}", new Object[] {m, "a", "b", M, e}); |
| 782 | parse("{null:'b'}", new Object[] {m, "null", "b", M, e}); |
| 783 | parse("{true: 'b'}", new Object[] {m, "true", "b", M, e}); |
| 784 | parse("{ false :'b'}", new Object[] {m, "false", "b", M, e}); |
| 785 | parse( |