Skip to content

Commit

Permalink
Merge pull request #214 from caselas/replace_multi_json
Browse files Browse the repository at this point in the history
Replace multi_json with stdlib json
  • Loading branch information
greatuserongithub committed Jun 24, 2013
2 parents 82e351f + 1cbb101 commit 88bc004
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 18 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ gem 'cucumber', '~> 0.7'
gem 'fakeweb', '~> 1.2'
gem 'rspec', '~> 1.3'
gem 'mongrel', '1.2.0.pre2'
gem 'multi_json', '~> 1.3'

group :development do
gem 'guard'
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ gem install httparty

## Requirements

* multi_json and multi_xml
* Ruby 1.9.3 or higher
* multi_xml
* You like to party!

## Examples
Expand Down
4 changes: 3 additions & 1 deletion httparty.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Gem::Specification.new do |s|
s.summary = %q{Makes http fun! Also, makes consuming restful web services dead easy.}
s.description = %q{Makes http fun! Also, makes consuming restful web services dead easy.}

s.add_dependency 'multi_json', "~> 1.0"
s.required_ruby_version = '>= 1.9.3'

s.add_dependency 'json', "~> 1.8"
s.add_dependency 'multi_xml', ">= 0.5.2"

s.post_install_message = "When you HTTParty, you must party hard!"
Expand Down
2 changes: 1 addition & 1 deletion lib/httparty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require 'uri'
require 'zlib'
require 'multi_xml'
require 'multi_json'
require 'json'

require 'httparty/module_inheritable_attributes'
require 'httparty/cookie_hash'
Expand Down
7 changes: 1 addition & 6 deletions lib/httparty/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,7 @@ def xml
end

def json
# https://github.com/sferik/rails/commit/5e62670131dfa1718eaf21ff8dd3371395a5f1cc
if MultiJson.respond_to?(:adapter)
MultiJson.load(body)
else
MultiJson.decode(body)
end
JSON.load(body, nil)
end

def html
Expand Down
10 changes: 2 additions & 8 deletions spec/httparty/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,8 @@ def self.name; 'AtomParser'; end
subject.send(:xml)
end

it "parses json with MultiJson" do
MultiJson.should_receive(:load).with('body')
subject.send(:json)
end

it "uses MultiJson.decode if MultiJson does not respond to adapter" do
MultiJson.should_receive(:respond_to?).with(:adapter).and_return(false)
MultiJson.should_receive(:decode).with('body')
it "parses json with JSON" do
JSON.should_receive(:load).with('body', nil)
subject.send(:json)
end

Expand Down

0 comments on commit 88bc004

Please sign in to comment.