Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use ActiveSupport JSON parser if it is already loaded.

The `json` gem and ActiveSupport's JSON implementation are incompatible.  It seems better not to break already loaded code.
  • Loading branch information...
commit b149eed54d93b3940ead08fcb3d85b023885a137 1 parent 367f2a5
@pezra pezra authored committed
Showing with 8 additions and 4 deletions.
  1. +8 −4 lib/contacts/yahoo.rb
View
12 lib/contacts/yahoo.rb
@@ -5,8 +5,8 @@
require 'md5'
require 'net/https'
require 'uri'
-require 'json'
require 'yaml'
+require 'json' unless defined? ActiveSupport::JSON
module Contacts
# = How I can fetch Yahoo Contacts?
@@ -207,12 +207,16 @@ def access_address_book_api
# This method parses the JSON contacts document and returns an array
# contaning all the user's contacts.
#
- # ==== Paramaters
- # * json <String>:: A String the user's contacts ni JSON format
+ # ==== Parameters
+ # * json <String>:: A String of user's contacts in JSON format
#
def self.parse_contacts(json)
- people = JSON.parse(json)
contacts = []
+ people = if defined? ActiveSupport::JSON
+ ActiveSupport::JSON.decode(json)
+ else
+ JSON.parse(json)
+ end
people['contacts'].each do |contact|
name = nil
Please sign in to comment.
Something went wrong with that request. Please try again.