From 0cf0b824182fc643c4e295b7178b84e71fdded54 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 28 Nov 2007 09:22:57 +0000 Subject: * ext/json, lib/json, test/json: Update to JSON 1.1.2. (RubyForge#15447) * math.c: fix typo. -- M ChangeLog M math.c M ext/json/ext/generator/generator.c M ext/json/ext/parser/parser.rl M ext/json/ext/parser/parser.c M lib/json/version.rb M lib/json/editor.rb M lib/json/common.rb M lib/json/pure/parser.rb M test/json/test_json_unicode.rb M test/json/test_json_fixtures.rb M test/json/test_json_generate.rb M test/json/test_json_addition.rb M test/json/test_json.rb M test/json/runner.rb git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/json/pure/parser.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/json/pure') diff --git a/lib/json/pure/parser.rb b/lib/json/pure/parser.rb index 4d63464320..e886ba8d2c 100644 --- a/lib/json/pure/parser.rb +++ b/lib/json/pure/parser.rb @@ -58,6 +58,9 @@ module JSON # * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in # defiance of RFC 4627 to be parsed by the Parser. This option defaults # to false. + # * *create_additions*: If set to false, the Parser doesn't create + # additions even if a matchin class and create_id was found. This option + # defaults to true. def initialize(source, opts = {}) super if !opts.key?(:max_nesting) # defaults to 19 @@ -68,7 +71,9 @@ module JSON @max_nesting = 0 end @allow_nan = !!opts[:allow_nan] - @create_id = JSON.create_id + ca = true + ca = opts[:create_additions] if opts.key?(:create_additions) + @create_id = ca ? JSON.create_id : nil end alias source string @@ -235,11 +240,10 @@ module JSON if delim raise ParserError, "expected next name, value pair in object at '#{peek(20)}'!" end - if klassname = result[@create_id] + if @create_id and klassname = result[@create_id] klass = JSON.deep_const_get klassname break unless klass and klass.json_creatable? result = klass.json_create(result) - result end break when skip(IGNORE) -- cgit v1.2.3