summaryrefslogtreecommitdiff
path: root/test/json
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2020-01-30 12:48:05 +0100
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-09-25 17:28:42 +0900
commite1659af3724e2320e9f2f2bd7cf602686e8aa523 (patch)
treed97e3f3fef7109a3ebea4e8c39352fe89a0c6cd0 /test/json
parentc5ea060ef8cd6c0de9987d1a3546b79e99ebb35c (diff)
Add an option to escape forward slash character
Squashed commit of the following: commit 26d181059989279a79c433cedcd893b4f52e42ee Author: Francois Chagnon <francois.chagnon@jadedpixel.com> Date: Tue Sep 15 21:17:34 2015 +0000 add config options for escape_slash commit fa282334051b16df91ca097dd7304b46f3bc7719 Author: Francois Chagnon <francois.chagnon@jadedpixel.com> Date: Mon Feb 9 21:09:33 2015 +0000 add forward slash to escape character
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3581
Diffstat (limited to 'test/json')
-rwxr-xr-x[-rw-r--r--]test/json/json_generator_test.rb7
-rw-r--r--test/json/json_parser_test.rb4
2 files changed, 11 insertions, 0 deletions
diff --git a/test/json/json_generator_test.rb b/test/json/json_generator_test.rb
index ee19fa5..13d3b5a 100644..100755
--- a/test/json/json_generator_test.rb
+++ b/test/json/json_generator_test.rb
@@ -174,6 +174,7 @@ EOT
:ascii_only => false,
:buffer_initial_length => 1024,
:depth => 0,
+ :escape_slash => false,
:indent => " ",
:max_nesting => 100,
:object_nl => "\n",
@@ -190,6 +191,7 @@ EOT
:ascii_only => false,
:buffer_initial_length => 1024,
:depth => 0,
+ :escape_slash => false,
:indent => "",
:max_nesting => 100,
:object_nl => "",
@@ -206,6 +208,7 @@ EOT
:ascii_only => false,
:buffer_initial_length => 1024,
:depth => 0,
+ :escape_slash => false,
:indent => "",
:max_nesting => 0,
:object_nl => "",
@@ -394,6 +397,10 @@ EOT
json = '["/"]'
assert_equal json, generate(data)
#
+ data = [ '/' ]
+ json = '["\/"]'
+ assert_equal json, generate(data, :escape_slash => true)
+ #
data = ['"']
json = '["\""]'
assert_equal json, generate(data)
diff --git a/test/json/json_parser_test.rb b/test/json/json_parser_test.rb
index 9946dd9..514441e 100644
--- a/test/json/json_parser_test.rb
+++ b/test/json/json_parser_test.rb
@@ -293,6 +293,10 @@ EOT
json = '["\\\'"]'
data = ["'"]
assert_equal data, parse(json)
+
+ json = '["\/"]'
+ data = [ '/' ]
+ assert_equal data, parse(json)
end
class SubArray < Array