summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/json/common.rb9
-rw-r--r--lib/json/pure/generator.rb13
-rw-r--r--lib/json/pure/parser.rb16
3 files changed, 7 insertions, 31 deletions
diff --git a/lib/json/common.rb b/lib/json/common.rb
index c47938f..209c3e7 100644
--- a/lib/json/common.rb
+++ b/lib/json/common.rb
@@ -295,13 +295,13 @@ module JSON
# The global default options for the JSON.load method:
# :max_nesting: false
# :allow_nan: true
- # :quirks_mode: true
+ # :allow_null: true
attr_accessor :load_default_options
end
self.load_default_options = {
:max_nesting => false,
:allow_nan => true,
- :quirks_mode => true,
+ :allow_null => true,
:create_additions => true,
}
@@ -328,7 +328,7 @@ module JSON
elsif source.respond_to?(:read)
source = source.read
end
- if opts[:quirks_mode] && (source.nil? || source.empty?)
+ if opts[:allow_null] && (source.nil? || source.empty?)
source = 'null'
end
result = parse(source, opts)
@@ -357,13 +357,12 @@ module JSON
# The global default options for the JSON.dump method:
# :max_nesting: false
# :allow_nan: true
- # :quirks_mode: true
+ # :allow_null: true
attr_accessor :dump_default_options
end
self.dump_default_options = {
:max_nesting => false,
:allow_nan => true,
- :quirks_mode => true,
}
# Dumps _obj_ as a JSON string, i.e. calls generate on the object and returns
diff --git a/lib/json/pure/generator.rb b/lib/json/pure/generator.rb
index cc8b0fd..cf4afff 100644
--- a/lib/json/pure/generator.rb
+++ b/lib/json/pure/generator.rb
@@ -154,8 +154,6 @@ module JSON
# * *allow_nan*: true if NaN, Infinity, and -Infinity should be
# generated, otherwise an exception is thrown, if these values are
# encountered. This options defaults to false.
- # * *quirks_mode*: Enables quirks_mode for parser, that is for example
- # generating single JSON values instead of documents is possible.
def initialize(opts = {})
@indent = ''
@space = ''
@@ -164,7 +162,6 @@ module JSON
@array_nl = ''
@allow_nan = false
@ascii_only = false
- @quirks_mode = false
@buffer_initial_length = 1024
configure opts
end
@@ -190,10 +187,6 @@ module JSON
# the generated JSON, max_nesting = 0 if no maximum is checked.
attr_accessor :max_nesting
- # If this attribute is set to true, quirks mode is enabled, otherwise
- # it's disabled.
- attr_accessor :quirks_mode
-
# :stopdoc:
attr_reader :buffer_initial_length
@@ -233,11 +226,6 @@ module JSON
@ascii_only
end
- # Returns true, if quirks mode is enabled. Otherwise returns false.
- def quirks_mode?
- @quirks_mode
- end
-
# Configure this State instance with the Hash _opts_, and return
# itself.
def configure(opts)
@@ -259,7 +247,6 @@ module JSON
@allow_nan = !!opts[:allow_nan] if opts.key?(:allow_nan)
@ascii_only = opts[:ascii_only] if opts.key?(:ascii_only)
@depth = opts[:depth] || 0
- @quirks_mode = opts[:quirks_mode] if opts.key?(:quirks_mode)
@buffer_initial_length ||= opts[:buffer_initial_length]
if !opts.key?(:max_nesting) # defaults to 100
diff --git a/lib/json/pure/parser.rb b/lib/json/pure/parser.rb
index c96fadb..b2e841b 100644
--- a/lib/json/pure/parser.rb
+++ b/lib/json/pure/parser.rb
@@ -69,13 +69,9 @@ module JSON
# option defaults to false.
# * *object_class*: Defaults to Hash
# * *array_class*: Defaults to Array
- # * *quirks_mode*: Enables quirks_mode for parser, that is for example
- # parsing single JSON values instead of documents is possible.
def initialize(source, opts = {})
opts ||= {}
- unless @quirks_mode = opts[:quirks_mode]
- source = convert_encoding source
- end
+ source = convert_encoding source
super source
if !opts.key?(:max_nesting) # defaults to 100
@max_nesting = 100
@@ -102,10 +98,6 @@ module JSON
alias source string
- def quirks_mode?
- !!@quirks_mode
- end
-
def reset
super
@current_nesting = 0
@@ -138,10 +130,8 @@ module JSON
raise TypeError,
"#{source.inspect} is not like a string"
end
- if defined?(::Encoding)
- source = source.encode(::Encoding::UTF_8)
- source.force_encoding(::Encoding::ASCII_8BIT)
- end
+ source = source.encode(::Encoding::UTF_8)
+ source.force_encoding(::Encoding::ASCII_8BIT)
source
end