diff --git a/httparty.gemspec b/httparty.gemspec index 116d087..f6219f4 100644 --- a/httparty.gemspec +++ b/httparty.gemspec @@ -13,6 +13,8 @@ Gem::Specification.new do |s| s.description = %q{Makes http fun! Also, makes consuming restful web services dead easy.} s.add_dependency 'crack', HTTParty::CRACK_DEPENDENCY + s.add_dependency 'multi_json' + s.add_dependency 'multi_xml' s.add_development_dependency "activesupport", "~> 2.3" s.add_development_dependency "cucumber", "~> 0.7" diff --git a/lib/httparty.rb b/lib/httparty.rb index e502c96..b275363 100644 --- a/lib/httparty.rb +++ b/lib/httparty.rb @@ -4,6 +4,8 @@ require 'net/https' require 'uri' require 'zlib' require 'crack' +require 'multi_xml' +require 'multi_json' require 'httparty/module_inheritable_attributes' require 'httparty/cookie_hash' diff --git a/lib/httparty/parser.rb b/lib/httparty/parser.rb index 68be2ae..6eed27d 100644 --- a/lib/httparty/parser.rb +++ b/lib/httparty/parser.rb @@ -109,11 +109,11 @@ module HTTParty protected def xml - Crack::XML.parse(body) + MultiXml.parse(body) end def json - Crack::JSON.parse(body) + MultiJson.decode(body) end def yaml diff --git a/spec/httparty/parser_spec.rb b/spec/httparty/parser_spec.rb index 330c038..9bb0d28 100644 --- a/spec/httparty/parser_spec.rb +++ b/spec/httparty/parser_spec.rb @@ -129,13 +129,13 @@ describe HTTParty::Parser do HTTParty::Parser.new('body', nil) end - it "parses xml with Crack" do - Crack::XML.should_receive(:parse).with('body') + it "parses xml with MultiXml" do + MultiXml.should_receive(:parse).with('body') subject.send(:xml) end - it "parses json with Crack" do - Crack::JSON.should_receive(:parse).with('body') + it "parses json with MultiJson" do + MultiJson.should_receive(:decode).with('body') subject.send(:json) end