Skip to content

Commit

Permalink
Revert "Merge pull request #9126 from mbarb0sa/bugfix/json-decoding-i…
Browse files Browse the repository at this point in the history
…n-rails-3-0-stable"

This reverts commit 360af4e, reversing
changes made to f93d046.
  • Loading branch information
tenderlove committed Feb 11, 2013
1 parent 182d4e3 commit f2839f1
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/json/backends/jsongem.rb
Expand Up @@ -12,7 +12,7 @@ def decode(json)
if json.respond_to?(:read) if json.respond_to?(:read)
json = json.read json = json.read
end end
data = ::JSON.load(json) data = ::JSON.parse(json)
if ActiveSupport.parse_json_times if ActiveSupport.parse_json_times
convert_dates_from(data) convert_dates_from(data)
else else
Expand Down
1 change: 0 additions & 1 deletion activesupport/lib/active_support/json/backends/okjson.rb
Expand Up @@ -63,7 +63,6 @@ def textparse(ts)


typ, _, val = ts[0] typ, _, val = ts[0]
case typ case typ
when :str, :val then valparse(ts)
when '{' then objparse(ts) when '{' then objparse(ts)
when '[' then arrparse(ts) when '[' then arrparse(ts)
else else
Expand Down
11 changes: 1 addition & 10 deletions activesupport/test/json/decoding_test.rb
Expand Up @@ -51,10 +51,7 @@ class TestJSONDecoding < ActiveSupport::TestCase
# tests escaping of "\n" char with Yaml backend # tests escaping of "\n" char with Yaml backend
%q({"a":"\n"}) => {"a"=>"\n"}, %q({"a":"\n"}) => {"a"=>"\n"},
%q({"a":"\u000a"}) => {"a"=>"\n"}, %q({"a":"\u000a"}) => {"a"=>"\n"},
%q({"a":"Line1\u000aLine2"}) => {"a"=>"Line1\nLine2"}, %q({"a":"Line1\u000aLine2"}) => {"a"=>"Line1\nLine2"}
"\"foobar\"" => "foobar",
"42" => 42,
"null" => nil
} }


# load the default JSON backend # load the default JSON backend
Expand Down Expand Up @@ -90,11 +87,5 @@ class TestJSONDecoding < ActiveSupport::TestCase
def test_failed_json_decoding def test_failed_json_decoding
assert_raise(ActiveSupport::JSON.parse_error) { ActiveSupport::JSON.decode(%({: 1})) } assert_raise(ActiveSupport::JSON.parse_error) { ActiveSupport::JSON.decode(%({: 1})) }
end end

def test_decoding_of_json_encoded_string
assert_equal "foobar", ActiveSupport::JSON.decode(ActiveSupport::JSON.encode("foobar"))
assert_equal 42, ActiveSupport::JSON.decode(ActiveSupport::JSON.encode(42))
assert_equal nil, ActiveSupport::JSON.decode(ActiveSupport::JSON.encode(nil))
end
end end


0 comments on commit f2839f1

Please sign in to comment.