diff --git a/lib/json.rb b/lib/json.rb index 8b1673d5..c28e853e 100644 --- a/lib/json.rb +++ b/lib/json.rb @@ -378,13 +378,13 @@ # json1 = JSON.generate(ruby) # ruby1 = JSON.parse(json1, create_additions: true) # # Make a nice display. -# display = < {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]} # @@ -445,17 +445,17 @@ class << self # parse(source, opts); see #parse. # # Source for following examples: - # source = <<-EOT - # { - # "name": "Dave", - # "age" :40, - # "hats": [ - # "Cattleman's", - # "Panama", - # "Tophat" - # ] - # } - # EOT + # source = <<~JSON + # { + # "name": "Dave", + # "age" :40, + # "hats": [ + # "Cattleman's", + # "Panama", + # "Tophat" + # ] + # } + # JSON # # Load a \String: # ruby = JSON.load(source) diff --git a/test/json/json_generator_test.rb b/test/json/json_generator_test.rb index 32712c83..01e412c9 100755 --- a/test/json/json_generator_test.rb +++ b/test/json/json_generator_test.rb @@ -19,24 +19,24 @@ def setup } @json2 = '{"a":2,"b":3.141,"c":"c","d":[1,"b",3.14],"e":{"foo":"bar"},' + '"g":"\\"\\u0000\\u001f","h":1000.0,"i":0.001}' - @json3 = <<'EOT'.chomp -{ - "a": 2, - "b": 3.141, - "c": "c", - "d": [ - 1, - "b", - 3.14 - ], - "e": { - "foo": "bar" - }, - "g": "\"\u0000\u001f", - "h": 1000.0, - "i": 0.001 -} -EOT + @json3 = <<~'JSON'.chomp + { + "a": 2, + "b": 3.141, + "c": "c", + "d": [ + 1, + "b", + 3.14 + ], + "e": { + "foo": "bar" + }, + "g": "\"\u0000\u001f", + "h": 1000.0, + "i": 0.001 + } + JSON end def silence @@ -93,13 +93,13 @@ def test_generate_pretty assert_equal('{}', json) json = pretty_generate({1=>{}, 2=>[], 3=>4}) - assert_equal(<<'EOT'.chomp, json) -{ - "1": {}, - "2": [], - "3": 4 -} -EOT + assert_equal(<<~'JSON'.chomp, json) + { + "1": {}, + "2": [], + "3": 4 + } + JSON json = pretty_generate(@hash) # hashes aren't (insertion) ordered on every ruby implementation @@ -108,11 +108,11 @@ def test_generate_pretty parsed_json = parse(json) assert_equal(@hash, parsed_json) json = pretty_generate({1=>2}) - assert_equal(<<'EOT'.chomp, json) -{ - "1": 2 -} -EOT + assert_equal(<<~'JSON'.chomp, json) + { + "1": 2 + } + JSON parsed_json = parse(json) assert_equal({"1"=>2}, parsed_json) assert_equal '666', pretty_generate(666) @@ -121,14 +121,14 @@ def test_generate_pretty def test_generate_custom state = State.new(:space_before => " ", :space => " ", :indent => "", :object_nl => "\n", :array_nl => "") json = generate({1=>{2=>3,4=>[5,6]}}, state) - assert_equal(<<'EOT'.chomp, json) -{ -"1" : { -"2" : 3, -"4" : [5,6] -} -} -EOT + assert_equal(<<~'JSON'.chomp, json) + { + "1" : { + "2" : 3, + "4" : [5,6] + } + } + JSON end def test_fast_generate diff --git a/test/json/json_parser_test.rb b/test/json/json_parser_test.rb index 8d3c0c17..ffc67ef6 100644 --- a/test/json/json_parser_test.rb +++ b/test/json/json_parser_test.rb @@ -247,50 +247,50 @@ def test_freeze end def test_parse_comments - json = < "value1", "key2" => "value2", "key3" => "value3" }, parse(json)) - json = < "value1" }, parse(json)) - json = < "value1" }, parse(json)) end