summaryrefslogtreecommitdiff
path: root/lib/json
diff options
context:
space:
mode:
authorFlorian Frank <flori@ping.de>2012-03-20 13:44:59 +0100
committerFlorian Frank <flori@ping.de>2012-03-20 13:44:59 +0100
commit8fd84e66cafa983b4922208950e4572b4734aa91 (patch)
tree314ee67cda95979886b94c70a4e2b032b683b2e9 /lib/json
parentdad9fbfbfbfcfe743563348f2c17aedecfabe803 (diff)
downloadjson-8fd84e66cafa983b4922208950e4572b4734aa91.tar.gz
Use C implementation and better regexp for pure
Diffstat (limited to 'lib/json')
-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