@@ -1681,8 +1681,9 @@ static VALUE convert_encoding(VALUE source)
16811681 * defiance of RFC 4627 to be parsed by the Parser. This option defaults to
16821682 * false.
16831683 * * *symbolize_names*: If set to true, returns symbols for the names
1684- * (keys) in a JSON object. Otherwise strings are returned, which is also
1685- * the default.
1684+ * (keys) in a JSON object. Otherwise strings are returned, which is
1685+ * also the default. It's not possible to use this option in
1686+ * conjunction with the *create_additions* option.
16861687 * * *create_additions*: If set to false, the Parser doesn't create
16871688 * additions even if a matching class and create_id was found. This option
16881689 * defaults to false.
@@ -1733,6 +1734,11 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
17331734 } else {
17341735 json -> create_additions = 0 ;
17351736 }
1737+ if (json -> symbolize_names && json -> create_additions ) {
1738+ rb_raise (rb_eArgError ,
1739+ "options :symbolize_names and :create_additions cannot be "
1740+ " used in conjunction" );
1741+ }
17361742 tmp = ID2SYM (i_create_id );
17371743 if (option_given_p (opts , tmp )) {
17381744 json -> create_id = rb_hash_aref (opts , tmp );
@@ -1778,15 +1784,15 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
17781784}
17791785
17801786
1781- #line 1782 "parser.c"
1787+ #line 1788 "parser.c"
17821788static const int JSON_start = 1 ;
17831789static const int JSON_first_final = 10 ;
17841790static const int JSON_error = 0 ;
17851791
17861792static const int JSON_en_main = 1 ;
17871793
17881794
1789- #line 690 "parser.rl"
1795+ #line 696 "parser.rl"
17901796
17911797
17921798/*
@@ -1803,16 +1809,16 @@ static VALUE cParser_parse(VALUE self)
18031809 GET_PARSER ;
18041810
18051811
1806- #line 1807 "parser.c"
1812+ #line 1813 "parser.c"
18071813 {
18081814 cs = JSON_start ;
18091815 }
18101816
1811- #line 706 "parser.rl"
1817+ #line 712 "parser.rl"
18121818 p = json -> source ;
18131819 pe = p + json -> len ;
18141820
1815- #line 1816 "parser.c"
1821+ #line 1822 "parser.c"
18161822 {
18171823 if ( p == pe )
18181824 goto _test_eof ;
@@ -1846,7 +1852,7 @@ case 1:
18461852cs = 0 ;
18471853 goto _out ;
18481854tr2 :
1849- #line 682 "parser.rl"
1855+ #line 688 "parser.rl"
18501856 {
18511857 char * np = JSON_parse_value (json , p , pe , & result );
18521858 if (np == NULL ) { p -- ; {p ++ ; cs = 10 ; goto _out ;} } else {p = (( np ))- 1 ;}
@@ -1856,7 +1862,7 @@ cs = 0;
18561862 if ( ++ p == pe )
18571863 goto _test_eof10 ;
18581864case 10 :
1859- #line 1860 "parser.c"
1865+ #line 1866 "parser.c"
18601866 switch ( (* p ) ) {
18611867 case 13 : goto st10 ;
18621868 case 32 : goto st10 ;
@@ -1945,7 +1951,7 @@ case 9:
19451951 _out : {}
19461952 }
19471953
1948- #line 709 "parser.rl"
1954+ #line 715 "parser.rl"
19491955
19501956 if (cs >= JSON_first_final && p == pe ) {
19511957 return result ;
0 commit comments