summaryrefslogtreecommitdiff
path: root/lib/json/pure/generator.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/json/pure/generator.rb')
-rw-r--r--lib/json/pure/generator.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/json/pure/generator.rb b/lib/json/pure/generator.rb
index 9141ae5..3d5f09f 100644
--- a/lib/json/pure/generator.rb
+++ b/lib/json/pure/generator.rb
@@ -255,8 +255,12 @@ module JSON
# GeneratorError exception.
def generate(obj)
result = obj.to_json(self)
- if !@quirks_mode && result !~ /\A\s*(?:\[.*\]|\{.*\})\s*\Z/m
- raise GeneratorError, "only generation of JSON objects or arrays allowed"
+ unless @quirks_mode
+ unless result =~ /\A\s*\[/ && result =~ /\]\s*\Z/ ||
+ result =~ /\A\s*\{/ && result =~ /\}\s*\Z/
+ then
+ raise GeneratorError, "only generation of JSON objects or arrays allowed"
+ end
end
result
end