json_pure 1.6.6 → 1.6.7

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,5 @@
1
+ 2012-04-27 (1.6.7)
2
+ * Fix possible crash when trying to parse nil value.
1
3
  2012-02-11 (1.6.6)
2
4
  * Propagate src encoding to values made from it (fixes 1.9 mode converting
3
5
  everything to ascii-8bit; harmless for 1.8 mode too) (Thomas E. Enebo
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.6
1
+ 1.6.7
@@ -860,7 +860,7 @@ static VALUE cState_partial_generate(VALUE self, VALUE obj)
860
860
  static int isArrayOrObject(VALUE string)
861
861
  {
862
862
  long string_len = RSTRING_LEN(string);
863
- char c, *p = RSTRING_PTR(string), *q = p + string_len - 1;
863
+ char *p = RSTRING_PTR(string), *q = p + string_len - 1;
864
864
  if (string_len < 2) return 0;
865
865
  for (; p < q && isspace(*p); p++);
866
866
  for (; q > p && isspace(*q); q--);
@@ -1721,6 +1721,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
1721
1721
  source = convert_encoding(StringValue(source));
1722
1722
  }
1723
1723
  json->current_nesting = 0;
1724
+ StringValue(source);
1724
1725
  json->len = RSTRING_LEN(source);
1725
1726
  json->source = RSTRING_PTR(source);;
1726
1727
  json->Vsource = source;
@@ -1728,7 +1729,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
1728
1729
  }
1729
1730
 
1730
1731
 
1731
- #line 1732 "parser.c"
1732
+ #line 1733 "parser.c"
1732
1733
  static const int JSON_start = 1;
1733
1734
  static const int JSON_first_final = 10;
1734
1735
  static const int JSON_error = 0;
@@ -1736,7 +1737,7 @@ static const int JSON_error = 0;
1736
1737
  static const int JSON_en_main = 1;
1737
1738
 
1738
1739
 
1739
- #line 739 "parser.rl"
1740
+ #line 740 "parser.rl"
1740
1741
 
1741
1742
 
1742
1743
  static VALUE cParser_parse_strict(VALUE self)
@@ -1747,16 +1748,16 @@ static VALUE cParser_parse_strict(VALUE self)
1747
1748
  GET_PARSER;
1748
1749
 
1749
1750
 
1750
- #line 1751 "parser.c"
1751
+ #line 1752 "parser.c"
1751
1752
  {
1752
1753
  cs = JSON_start;
1753
1754
  }
1754
1755
 
1755
- #line 749 "parser.rl"
1756
+ #line 750 "parser.rl"
1756
1757
  p = json->source;
1757
1758
  pe = p + json->len;
1758
1759
 
1759
- #line 1760 "parser.c"
1760
+ #line 1761 "parser.c"
1760
1761
  {
1761
1762
  if ( p == pe )
1762
1763
  goto _test_eof;
@@ -1812,7 +1813,7 @@ case 5:
1812
1813
  goto st1;
1813
1814
  goto st5;
1814
1815
  tr3:
1815
- #line 728 "parser.rl"
1816
+ #line 729 "parser.rl"
1816
1817
  {
1817
1818
  char *np;
1818
1819
  json->current_nesting = 1;
@@ -1821,7 +1822,7 @@ tr3:
1821
1822
  }
1822
1823
  goto st10;
1823
1824
  tr4:
1824
- #line 721 "parser.rl"
1825
+ #line 722 "parser.rl"
1825
1826
  {
1826
1827
  char *np;
1827
1828
  json->current_nesting = 1;
@@ -1833,7 +1834,7 @@ st10:
1833
1834
  if ( ++p == pe )
1834
1835
  goto _test_eof10;
1835
1836
  case 10:
1836
- #line 1837 "parser.c"
1837
+ #line 1838 "parser.c"
1837
1838
  switch( (*p) ) {
1838
1839
  case 13: goto st10;
1839
1840
  case 32: goto st10;
@@ -1890,7 +1891,7 @@ case 9:
1890
1891
  _out: {}
1891
1892
  }
1892
1893
 
1893
- #line 752 "parser.rl"
1894
+ #line 753 "parser.rl"
1894
1895
 
1895
1896
  if (cs >= JSON_first_final && p == pe) {
1896
1897
  return result;
@@ -1902,7 +1903,7 @@ case 9:
1902
1903
 
1903
1904
 
1904
1905
 
1905
- #line 1906 "parser.c"
1906
+ #line 1907 "parser.c"
1906
1907
  static const int JSON_quirks_mode_start = 1;
1907
1908
  static const int JSON_quirks_mode_first_final = 10;
1908
1909
  static const int JSON_quirks_mode_error = 0;
@@ -1910,7 +1911,7 @@ static const int JSON_quirks_mode_error = 0;
1910
1911
  static const int JSON_quirks_mode_en_main = 1;
1911
1912
 
1912
1913
 
1913
- #line 777 "parser.rl"
1914
+ #line 778 "parser.rl"
1914
1915
 
1915
1916
 
1916
1917
  static VALUE cParser_parse_quirks_mode(VALUE self)
@@ -1921,16 +1922,16 @@ static VALUE cParser_parse_quirks_mode(VALUE self)
1921
1922
  GET_PARSER;
1922
1923
 
1923
1924
 
1924
- #line 1925 "parser.c"
1925
+ #line 1926 "parser.c"
1925
1926
  {
1926
1927
  cs = JSON_quirks_mode_start;
1927
1928
  }
1928
1929
 
1929
- #line 787 "parser.rl"
1930
+ #line 788 "parser.rl"
1930
1931
  p = json->source;
1931
1932
  pe = p + json->len;
1932
1933
 
1933
- #line 1934 "parser.c"
1934
+ #line 1935 "parser.c"
1934
1935
  {
1935
1936
  if ( p == pe )
1936
1937
  goto _test_eof;
@@ -1964,7 +1965,7 @@ st0:
1964
1965
  cs = 0;
1965
1966
  goto _out;
1966
1967
  tr2:
1967
- #line 769 "parser.rl"
1968
+ #line 770 "parser.rl"
1968
1969
  {
1969
1970
  char *np = JSON_parse_value(json, p, pe, &result);
1970
1971
  if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
@@ -1974,7 +1975,7 @@ st10:
1974
1975
  if ( ++p == pe )
1975
1976
  goto _test_eof10;
1976
1977
  case 10:
1977
- #line 1978 "parser.c"
1978
+ #line 1979 "parser.c"
1978
1979
  switch( (*p) ) {
1979
1980
  case 13: goto st10;
1980
1981
  case 32: goto st10;
@@ -2063,7 +2064,7 @@ case 9:
2063
2064
  _out: {}
2064
2065
  }
2065
2066
 
2066
- #line 790 "parser.rl"
2067
+ #line 791 "parser.rl"
2067
2068
 
2068
2069
  if (cs >= JSON_quirks_mode_first_final && p == pe) {
2069
2070
  return result;
@@ -705,6 +705,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
705
705
  source = convert_encoding(StringValue(source));
706
706
  }
707
707
  json->current_nesting = 0;
708
+ StringValue(source);
708
709
  json->len = RSTRING_LEN(source);
709
710
  json->source = RSTRING_PTR(source);;
710
711
  json->Vsource = source;
data/json.gemspec CHANGED
@@ -2,23 +2,23 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "json"
5
- s.version = "1.6.6"
5
+ s.version = "1.6.7"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Florian Frank"]
9
- s.date = "2012-03-26"
9
+ s.date = "2012-04-28"
10
10
  s.description = "This is a JSON implementation as a Ruby extension in C."
11
11
  s.email = "flori@ping.de"
12
- s.extensions = ["ext/json/ext/generator/extconf.rb", "ext/json/ext/parser/extconf.rb"]
12
+ s.extensions = ["ext/json/ext/parser/extconf.rb", "ext/json/ext/generator/extconf.rb"]
13
13
  s.extra_rdoc_files = ["README.rdoc"]
14
- s.files = [".gitignore", ".travis.yml", "CHANGES", "COPYING", "COPYING-json-jruby", "GPL", "Gemfile", "README-json-jruby.markdown", "README.rdoc", "Rakefile", "TODO", "VERSION", "data/example.json", "data/index.html", "data/prototype.js", "diagrams/.keep", "ext/json/ext/fbuffer/fbuffer.h", "ext/json/ext/generator/extconf.rb", "ext/json/ext/generator/generator.c", "ext/json/ext/generator/generator.h", "ext/json/ext/parser/extconf.rb", "ext/json/ext/parser/parser.c", "ext/json/ext/parser/parser.h", "ext/json/ext/parser/parser.rl", "install.rb", "java/src/json/ext/ByteListTranscoder.java", "java/src/json/ext/Generator.java", "java/src/json/ext/GeneratorMethods.java", "java/src/json/ext/GeneratorService.java", "java/src/json/ext/GeneratorState.java", "java/src/json/ext/OptionsReader.java", "java/src/json/ext/Parser.java", "java/src/json/ext/Parser.rl", "java/src/json/ext/ParserService.java", "java/src/json/ext/RuntimeInfo.java", "java/src/json/ext/StringDecoder.java", "java/src/json/ext/StringEncoder.java", "java/src/json/ext/Utils.java", "json-java.gemspec", "json.gemspec", "json_pure.gemspec", "lib/json.rb", "lib/json/add/bigdecimal.rb", "lib/json/add/complex.rb", "lib/json/add/core.rb", "lib/json/add/date.rb", "lib/json/add/date_time.rb", "lib/json/add/exception.rb", "lib/json/add/ostruct.rb", "lib/json/add/range.rb", "lib/json/add/rational.rb", "lib/json/add/regexp.rb", "lib/json/add/struct.rb", "lib/json/add/symbol.rb", "lib/json/add/time.rb", "lib/json/common.rb", "lib/json/ext.rb", "lib/json/ext/.keep", "lib/json/pure.rb", "lib/json/pure/generator.rb", "lib/json/pure/parser.rb", "lib/json/version.rb", "tests/fixtures/fail1.json", "tests/fixtures/fail10.json", "tests/fixtures/fail11.json", "tests/fixtures/fail12.json", "tests/fixtures/fail13.json", "tests/fixtures/fail14.json", "tests/fixtures/fail18.json", "tests/fixtures/fail19.json", "tests/fixtures/fail2.json", "tests/fixtures/fail20.json", "tests/fixtures/fail21.json", "tests/fixtures/fail22.json", "tests/fixtures/fail23.json", "tests/fixtures/fail24.json", "tests/fixtures/fail25.json", "tests/fixtures/fail27.json", "tests/fixtures/fail28.json", "tests/fixtures/fail3.json", "tests/fixtures/fail4.json", "tests/fixtures/fail5.json", "tests/fixtures/fail6.json", "tests/fixtures/fail7.json", "tests/fixtures/fail8.json", "tests/fixtures/fail9.json", "tests/fixtures/pass1.json", "tests/fixtures/pass15.json", "tests/fixtures/pass16.json", "tests/fixtures/pass17.json", "tests/fixtures/pass2.json", "tests/fixtures/pass26.json", "tests/fixtures/pass3.json", "tests/setup_variant.rb", "tests/test_json.rb", "tests/test_json_addition.rb", "tests/test_json_encoding.rb", "tests/test_json_fixtures.rb", "tests/test_json_generate.rb", "tests/test_json_string_matching.rb", "tests/test_json_unicode.rb", "tools/fuzz.rb", "tools/server.rb", "./tests/test_json.rb", "./tests/test_json_addition.rb", "./tests/test_json_encoding.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_generate.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_unicode.rb"]
14
+ s.files = [".gitignore", ".travis.yml", "CHANGES", "COPYING", "COPYING-json-jruby", "GPL", "Gemfile", "README-json-jruby.markdown", "README.rdoc", "Rakefile", "TODO", "VERSION", "data/example.json", "data/index.html", "data/prototype.js", "diagrams/.keep", "ext/json/ext/fbuffer/fbuffer.h", "ext/json/ext/generator/extconf.rb", "ext/json/ext/generator/generator.c", "ext/json/ext/generator/generator.h", "ext/json/ext/parser/extconf.rb", "ext/json/ext/parser/parser.c", "ext/json/ext/parser/parser.h", "ext/json/ext/parser/parser.rl", "install.rb", "java/src/json/ext/ByteListTranscoder.java", "java/src/json/ext/Generator.java", "java/src/json/ext/GeneratorMethods.java", "java/src/json/ext/GeneratorService.java", "java/src/json/ext/GeneratorState.java", "java/src/json/ext/OptionsReader.java", "java/src/json/ext/Parser.java", "java/src/json/ext/Parser.rl", "java/src/json/ext/ParserService.java", "java/src/json/ext/RuntimeInfo.java", "java/src/json/ext/StringDecoder.java", "java/src/json/ext/StringEncoder.java", "java/src/json/ext/Utils.java", "json-java.gemspec", "json.gemspec", "json_pure.gemspec", "lib/json.rb", "lib/json/add/bigdecimal.rb", "lib/json/add/complex.rb", "lib/json/add/core.rb", "lib/json/add/date.rb", "lib/json/add/date_time.rb", "lib/json/add/exception.rb", "lib/json/add/ostruct.rb", "lib/json/add/range.rb", "lib/json/add/rational.rb", "lib/json/add/regexp.rb", "lib/json/add/struct.rb", "lib/json/add/symbol.rb", "lib/json/add/time.rb", "lib/json/common.rb", "lib/json/ext.rb", "lib/json/ext/.keep", "lib/json/light_object.rb", "lib/json/pure.rb", "lib/json/pure/generator.rb", "lib/json/pure/parser.rb", "lib/json/version.rb", "tests/fixtures/fail1.json", "tests/fixtures/fail10.json", "tests/fixtures/fail11.json", "tests/fixtures/fail12.json", "tests/fixtures/fail13.json", "tests/fixtures/fail14.json", "tests/fixtures/fail18.json", "tests/fixtures/fail19.json", "tests/fixtures/fail2.json", "tests/fixtures/fail20.json", "tests/fixtures/fail21.json", "tests/fixtures/fail22.json", "tests/fixtures/fail23.json", "tests/fixtures/fail24.json", "tests/fixtures/fail25.json", "tests/fixtures/fail27.json", "tests/fixtures/fail28.json", "tests/fixtures/fail3.json", "tests/fixtures/fail4.json", "tests/fixtures/fail5.json", "tests/fixtures/fail6.json", "tests/fixtures/fail7.json", "tests/fixtures/fail8.json", "tests/fixtures/fail9.json", "tests/fixtures/pass1.json", "tests/fixtures/pass15.json", "tests/fixtures/pass16.json", "tests/fixtures/pass17.json", "tests/fixtures/pass2.json", "tests/fixtures/pass26.json", "tests/fixtures/pass3.json", "tests/setup_variant.rb", "tests/test_json.rb", "tests/test_json_addition.rb", "tests/test_json_encoding.rb", "tests/test_json_fixtures.rb", "tests/test_json_generate.rb", "tests/test_json_string_matching.rb", "tests/test_json_unicode.rb", "tools/fuzz.rb", "tools/server.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_unicode.rb", "./tests/test_json_addition.rb", "./tests/test_json_generate.rb", "./tests/test_json_encoding.rb", "./tests/test_json.rb"]
15
15
  s.homepage = "http://flori.github.com/json"
16
16
  s.rdoc_options = ["--title", "JSON implemention for Ruby", "--main", "README.rdoc"]
17
17
  s.require_paths = ["ext/json/ext", "ext", "lib"]
18
18
  s.rubyforge_project = "json"
19
- s.rubygems_version = "1.8.21"
19
+ s.rubygems_version = "1.8.23"
20
20
  s.summary = "JSON Implementation for Ruby"
21
- s.test_files = ["./tests/test_json.rb", "./tests/test_json_addition.rb", "./tests/test_json_encoding.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_generate.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_unicode.rb"]
21
+ s.test_files = ["./tests/test_json_string_matching.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_unicode.rb", "./tests/test_json_addition.rb", "./tests/test_json_generate.rb", "./tests/test_json_encoding.rb", "./tests/test_json.rb"]
22
22
 
23
23
  if s.respond_to? :specification_version then
24
24
  s.specification_version = 3
data/json_pure.gemspec CHANGED
@@ -2,22 +2,22 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "json_pure"
5
- s.version = "1.6.6"
5
+ s.version = "1.6.7"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Florian Frank"]
9
- s.date = "2012-03-26"
9
+ s.date = "2012-04-28"
10
10
  s.description = "This is a JSON implementation in pure Ruby."
11
11
  s.email = "flori@ping.de"
12
12
  s.extra_rdoc_files = ["README.rdoc"]
13
- s.files = [".gitignore", ".travis.yml", "CHANGES", "COPYING", "COPYING-json-jruby", "GPL", "Gemfile", "README-json-jruby.markdown", "README.rdoc", "Rakefile", "TODO", "VERSION", "data/example.json", "data/index.html", "data/prototype.js", "diagrams/.keep", "ext/json/ext/fbuffer/fbuffer.h", "ext/json/ext/generator/extconf.rb", "ext/json/ext/generator/generator.c", "ext/json/ext/generator/generator.h", "ext/json/ext/parser/extconf.rb", "ext/json/ext/parser/parser.c", "ext/json/ext/parser/parser.h", "ext/json/ext/parser/parser.rl", "install.rb", "java/src/json/ext/ByteListTranscoder.java", "java/src/json/ext/Generator.java", "java/src/json/ext/GeneratorMethods.java", "java/src/json/ext/GeneratorService.java", "java/src/json/ext/GeneratorState.java", "java/src/json/ext/OptionsReader.java", "java/src/json/ext/Parser.java", "java/src/json/ext/Parser.rl", "java/src/json/ext/ParserService.java", "java/src/json/ext/RuntimeInfo.java", "java/src/json/ext/StringDecoder.java", "java/src/json/ext/StringEncoder.java", "java/src/json/ext/Utils.java", "json-java.gemspec", "json.gemspec", "json_pure.gemspec", "lib/json.rb", "lib/json/add/bigdecimal.rb", "lib/json/add/complex.rb", "lib/json/add/core.rb", "lib/json/add/date.rb", "lib/json/add/date_time.rb", "lib/json/add/exception.rb", "lib/json/add/ostruct.rb", "lib/json/add/range.rb", "lib/json/add/rational.rb", "lib/json/add/regexp.rb", "lib/json/add/struct.rb", "lib/json/add/symbol.rb", "lib/json/add/time.rb", "lib/json/common.rb", "lib/json/ext.rb", "lib/json/ext/.keep", "lib/json/pure.rb", "lib/json/pure/generator.rb", "lib/json/pure/parser.rb", "lib/json/version.rb", "tests/fixtures/fail1.json", "tests/fixtures/fail10.json", "tests/fixtures/fail11.json", "tests/fixtures/fail12.json", "tests/fixtures/fail13.json", "tests/fixtures/fail14.json", "tests/fixtures/fail18.json", "tests/fixtures/fail19.json", "tests/fixtures/fail2.json", "tests/fixtures/fail20.json", "tests/fixtures/fail21.json", "tests/fixtures/fail22.json", "tests/fixtures/fail23.json", "tests/fixtures/fail24.json", "tests/fixtures/fail25.json", "tests/fixtures/fail27.json", "tests/fixtures/fail28.json", "tests/fixtures/fail3.json", "tests/fixtures/fail4.json", "tests/fixtures/fail5.json", "tests/fixtures/fail6.json", "tests/fixtures/fail7.json", "tests/fixtures/fail8.json", "tests/fixtures/fail9.json", "tests/fixtures/pass1.json", "tests/fixtures/pass15.json", "tests/fixtures/pass16.json", "tests/fixtures/pass17.json", "tests/fixtures/pass2.json", "tests/fixtures/pass26.json", "tests/fixtures/pass3.json", "tests/setup_variant.rb", "tests/test_json.rb", "tests/test_json_addition.rb", "tests/test_json_encoding.rb", "tests/test_json_fixtures.rb", "tests/test_json_generate.rb", "tests/test_json_string_matching.rb", "tests/test_json_unicode.rb", "tools/fuzz.rb", "tools/server.rb", "./tests/test_json.rb", "./tests/test_json_addition.rb", "./tests/test_json_encoding.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_generate.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_unicode.rb"]
13
+ s.files = [".gitignore", ".travis.yml", "CHANGES", "COPYING", "COPYING-json-jruby", "GPL", "Gemfile", "README-json-jruby.markdown", "README.rdoc", "Rakefile", "TODO", "VERSION", "data/example.json", "data/index.html", "data/prototype.js", "diagrams/.keep", "ext/json/ext/fbuffer/fbuffer.h", "ext/json/ext/generator/extconf.rb", "ext/json/ext/generator/generator.c", "ext/json/ext/generator/generator.h", "ext/json/ext/parser/extconf.rb", "ext/json/ext/parser/parser.c", "ext/json/ext/parser/parser.h", "ext/json/ext/parser/parser.rl", "install.rb", "java/src/json/ext/ByteListTranscoder.java", "java/src/json/ext/Generator.java", "java/src/json/ext/GeneratorMethods.java", "java/src/json/ext/GeneratorService.java", "java/src/json/ext/GeneratorState.java", "java/src/json/ext/OptionsReader.java", "java/src/json/ext/Parser.java", "java/src/json/ext/Parser.rl", "java/src/json/ext/ParserService.java", "java/src/json/ext/RuntimeInfo.java", "java/src/json/ext/StringDecoder.java", "java/src/json/ext/StringEncoder.java", "java/src/json/ext/Utils.java", "json-java.gemspec", "json.gemspec", "json_pure.gemspec", "lib/json.rb", "lib/json/add/bigdecimal.rb", "lib/json/add/complex.rb", "lib/json/add/core.rb", "lib/json/add/date.rb", "lib/json/add/date_time.rb", "lib/json/add/exception.rb", "lib/json/add/ostruct.rb", "lib/json/add/range.rb", "lib/json/add/rational.rb", "lib/json/add/regexp.rb", "lib/json/add/struct.rb", "lib/json/add/symbol.rb", "lib/json/add/time.rb", "lib/json/common.rb", "lib/json/ext.rb", "lib/json/ext/.keep", "lib/json/light_object.rb", "lib/json/pure.rb", "lib/json/pure/generator.rb", "lib/json/pure/parser.rb", "lib/json/version.rb", "tests/fixtures/fail1.json", "tests/fixtures/fail10.json", "tests/fixtures/fail11.json", "tests/fixtures/fail12.json", "tests/fixtures/fail13.json", "tests/fixtures/fail14.json", "tests/fixtures/fail18.json", "tests/fixtures/fail19.json", "tests/fixtures/fail2.json", "tests/fixtures/fail20.json", "tests/fixtures/fail21.json", "tests/fixtures/fail22.json", "tests/fixtures/fail23.json", "tests/fixtures/fail24.json", "tests/fixtures/fail25.json", "tests/fixtures/fail27.json", "tests/fixtures/fail28.json", "tests/fixtures/fail3.json", "tests/fixtures/fail4.json", "tests/fixtures/fail5.json", "tests/fixtures/fail6.json", "tests/fixtures/fail7.json", "tests/fixtures/fail8.json", "tests/fixtures/fail9.json", "tests/fixtures/pass1.json", "tests/fixtures/pass15.json", "tests/fixtures/pass16.json", "tests/fixtures/pass17.json", "tests/fixtures/pass2.json", "tests/fixtures/pass26.json", "tests/fixtures/pass3.json", "tests/setup_variant.rb", "tests/test_json.rb", "tests/test_json_addition.rb", "tests/test_json_encoding.rb", "tests/test_json_fixtures.rb", "tests/test_json_generate.rb", "tests/test_json_string_matching.rb", "tests/test_json_unicode.rb", "tools/fuzz.rb", "tools/server.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_unicode.rb", "./tests/test_json_addition.rb", "./tests/test_json_generate.rb", "./tests/test_json_encoding.rb", "./tests/test_json.rb"]
14
14
  s.homepage = "http://flori.github.com/json"
15
15
  s.rdoc_options = ["--title", "JSON implemention for ruby", "--main", "README.rdoc"]
16
16
  s.require_paths = ["lib"]
17
17
  s.rubyforge_project = "json"
18
- s.rubygems_version = "1.8.21"
18
+ s.rubygems_version = "1.8.23"
19
19
  s.summary = "JSON Implementation for Ruby"
20
- s.test_files = ["./tests/test_json.rb", "./tests/test_json_addition.rb", "./tests/test_json_encoding.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_generate.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_unicode.rb"]
20
+ s.test_files = ["./tests/test_json_string_matching.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_unicode.rb", "./tests/test_json_addition.rb", "./tests/test_json_generate.rb", "./tests/test_json_encoding.rb", "./tests/test_json.rb"]
21
21
 
22
22
  if s.respond_to? :specification_version then
23
23
  s.specification_version = 3
data/lib/json/common.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'json/version'
2
+ require 'json/light_object'
2
3
 
3
4
  module JSON
4
5
  class << self
@@ -0,0 +1,45 @@
1
+ require 'ostruct'
2
+
3
+ module JSON
4
+ class LightObject < OpenStruct
5
+ class << self
6
+ alias [] new
7
+
8
+ def json_create(data)
9
+ data = data.dup
10
+ data.delete JSON.create_id
11
+ self[data]
12
+ end
13
+ end
14
+
15
+ def to_hash
16
+ table
17
+ end
18
+
19
+ def [](name)
20
+ to_hash[name.to_sym]
21
+ end
22
+
23
+ def []=(name, value)
24
+ modifiable[name.to_sym] = value
25
+ end
26
+
27
+ def |(other)
28
+ self.class[other.to_hash.merge(to_hash)]
29
+ end
30
+
31
+ def as_json(*)
32
+ to_hash | { JSON.create_id => self.class.name }
33
+ end
34
+
35
+ def to_json(*a)
36
+ as_json.to_json(*a)
37
+ end
38
+
39
+ def method_missing(*a, &b)
40
+ to_hash.__send__(*a, &b)
41
+ rescue NoMethodError
42
+ super
43
+ end
44
+ end
45
+ end
data/lib/json/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module JSON
2
2
  # JSON version
3
- VERSION = '1.6.6'
3
+ VERSION = '1.6.7'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/tests/test_json.rb CHANGED
@@ -21,7 +21,7 @@ unless Array.method_defined?(:permutation)
21
21
  end
22
22
  end
23
23
 
24
- class TC_JSON < Test::Unit::TestCase
24
+ class TestJSON < Test::Unit::TestCase
25
25
  include JSON
26
26
 
27
27
  def setup
@@ -109,6 +109,8 @@ class TC_JSON < Test::Unit::TestCase
109
109
  def test_parse_json_primitive_values
110
110
  assert_raise(JSON::ParserError) { JSON.parse('') }
111
111
  assert_raise(JSON::ParserError) { JSON.parse('', :quirks_mode => true) }
112
+ assert_raise(TypeError) { JSON::Parser.new(nil).parse }
113
+ assert_raise(TypeError) { JSON::Parser.new(nil, :quirks_mode => true).parse }
112
114
  assert_raise(TypeError) { JSON.parse(nil) }
113
115
  assert_raise(TypeError) { JSON.parse(nil, :quirks_mode => true) }
114
116
  assert_raise(JSON::ParserError) { JSON.parse(' /* foo */ ') }
@@ -314,6 +316,16 @@ class TC_JSON < Test::Unit::TestCase
314
316
  assert res.item_set?
315
317
  end
316
318
 
319
+ def test_parse_light_object
320
+ res = parse('{"foo":"bar", "baz":{}}', :object_class => JSON::LightObject)
321
+ assert_equal(JSON::LightObject, res.class)
322
+ assert_equal "bar", res.foo
323
+ assert_equal "bar", res["foo"]
324
+ assert_equal "bar", res[:foo]
325
+ assert_equal "bar", res.to_hash[:foo]
326
+ assert_equal(JSON::LightObject, res.baz.class)
327
+ end
328
+
317
329
  def test_generate_core_subclasses_with_new_to_json
318
330
  obj = SubHash2["foo" => SubHash2["bar" => true]]
319
331
  obj_json = JSON(obj)
@@ -10,7 +10,7 @@ require 'json/add/bigdecimal'
10
10
  require 'json/add/ostruct'
11
11
  require 'date'
12
12
 
13
- class TC_JSONAddition < Test::Unit::TestCase
13
+ class TestJSONAddition < Test::Unit::TestCase
14
14
  include JSON
15
15
 
16
16
  class A
@@ -64,7 +64,7 @@ class TC_JSONAddition < Test::Unit::TestCase
64
64
 
65
65
  def to_json(*args)
66
66
  {
67
- 'json_class' => 'TC_JSONAddition::Nix',
67
+ 'json_class' => 'TestJSONAddition::Nix',
68
68
  }.to_json(*args)
69
69
  end
70
70
  end
@@ -88,7 +88,7 @@ class TC_JSONAddition < Test::Unit::TestCase
88
88
  a_hash = JSON.parse(json, :create_additions => false)
89
89
  assert_kind_of Hash, a_hash
90
90
  assert_equal(
91
- {"args"=>[666], "json_class"=>"TC_JSONAddition::A"}.sort_by { |k,| k },
91
+ {"args"=>[666], "json_class"=>"TestJSONAddition::A"}.sort_by { |k,| k },
92
92
  a_hash.sort_by { |k,| k }
93
93
  )
94
94
  end
@@ -97,7 +97,7 @@ class TC_JSONAddition < Test::Unit::TestCase
97
97
  b = B.new
98
98
  assert !B.json_creatable?
99
99
  json = generate(b)
100
- assert_equal({ "json_class"=>"TC_JSONAddition::B" }, JSON.parse(json))
100
+ assert_equal({ "json_class"=>"TestJSONAddition::B" }, JSON.parse(json))
101
101
  end
102
102
 
103
103
  def test_extended_json_fail2
@@ -4,7 +4,7 @@
4
4
  require 'test/unit'
5
5
  require File.join(File.dirname(__FILE__), 'setup_variant')
6
6
 
7
- class TC_JSONEncoding < Test::Unit::TestCase
7
+ class TestJSONEncoding < Test::Unit::TestCase
8
8
  include JSON
9
9
 
10
10
  def setup
@@ -4,7 +4,7 @@
4
4
  require 'test/unit'
5
5
  require File.join(File.dirname(__FILE__), 'setup_variant')
6
6
 
7
- class TC_JSONFixtures < Test::Unit::TestCase
7
+ class TestJSONFixtures < Test::Unit::TestCase
8
8
  def setup
9
9
  fixtures = File.join(File.dirname(__FILE__), 'fixtures/*.json')
10
10
  passed, failed = Dir[fixtures].partition { |f| f['pass'] }
@@ -4,7 +4,7 @@
4
4
  require 'test/unit'
5
5
  require File.join(File.dirname(__FILE__), 'setup_variant')
6
6
 
7
- class TC_JSONGenerate < Test::Unit::TestCase
7
+ class TestJSONGenerate < Test::Unit::TestCase
8
8
  include JSON
9
9
 
10
10
  def setup
@@ -6,7 +6,7 @@ require File.join(File.dirname(__FILE__), 'setup_variant')
6
6
  require 'stringio'
7
7
  require 'time'
8
8
 
9
- class TestJsonStringMatching < Test::Unit::TestCase
9
+ class TestJSONStringMatching < Test::Unit::TestCase
10
10
  include JSON
11
11
 
12
12
  class TestTime < ::Time
@@ -4,7 +4,7 @@
4
4
  require 'test/unit'
5
5
  require File.join(File.dirname(__FILE__), 'setup_variant')
6
6
 
7
- class TC_JSONUnicode < Test::Unit::TestCase
7
+ class TestJSONUnicode < Test::Unit::TestCase
8
8
  include JSON
9
9
 
10
10
  def test_unicode
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_pure
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.6
4
+ version: 1.6.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-26 00:00:00.000000000 Z
12
+ date: 2012-04-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: permutation
@@ -124,6 +124,7 @@ files:
124
124
  - lib/json/common.rb
125
125
  - lib/json/ext.rb
126
126
  - lib/json/ext/.keep
127
+ - lib/json/light_object.rb
127
128
  - lib/json/pure.rb
128
129
  - lib/json/pure/generator.rb
129
130
  - lib/json/pure/parser.rb
@@ -169,13 +170,13 @@ files:
169
170
  - tests/test_json_unicode.rb
170
171
  - tools/fuzz.rb
171
172
  - tools/server.rb
172
- - ./tests/test_json.rb
173
- - ./tests/test_json_addition.rb
174
- - ./tests/test_json_encoding.rb
175
- - ./tests/test_json_fixtures.rb
176
- - ./tests/test_json_generate.rb
177
173
  - ./tests/test_json_string_matching.rb
174
+ - ./tests/test_json_fixtures.rb
178
175
  - ./tests/test_json_unicode.rb
176
+ - ./tests/test_json_addition.rb
177
+ - ./tests/test_json_generate.rb
178
+ - ./tests/test_json_encoding.rb
179
+ - ./tests/test_json.rb
179
180
  homepage: http://flori.github.com/json
180
181
  licenses: []
181
182
  post_install_message:
@@ -194,7 +195,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
194
195
  version: '0'
195
196
  segments:
196
197
  - 0
197
- hash: -2915293540149116047
198
+ hash: 3357543127192015668
198
199
  required_rubygems_version: !ruby/object:Gem::Requirement
199
200
  none: false
200
201
  requirements:
@@ -203,15 +204,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
204
  version: '0'
204
205
  requirements: []
205
206
  rubyforge_project: json
206
- rubygems_version: 1.8.21
207
+ rubygems_version: 1.8.23
207
208
  signing_key:
208
209
  specification_version: 3
209
210
  summary: JSON Implementation for Ruby
210
211
  test_files:
211
- - ./tests/test_json.rb
212
- - ./tests/test_json_addition.rb
213
- - ./tests/test_json_encoding.rb
214
- - ./tests/test_json_fixtures.rb
215
- - ./tests/test_json_generate.rb
216
212
  - ./tests/test_json_string_matching.rb
213
+ - ./tests/test_json_fixtures.rb
217
214
  - ./tests/test_json_unicode.rb
215
+ - ./tests/test_json_addition.rb
216
+ - ./tests/test_json_generate.rb
217
+ - ./tests/test_json_encoding.rb
218
+ - ./tests/test_json.rb