Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace multi_json with stdlib json #214

Merged
merged 3 commits into from
Jun 24, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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