Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed JSON support when used as Rails plugin

  • Loading branch information...
commit d4facf42d61af1af9a1f7052b6769b721ad383b8 1 parent 23c1ae5
@jkrall jkrall authored
Showing with 6 additions and 2 deletions.
  1. +1 −1  lib/google_ajax.rb
  2. +5 −1 lib/google_ajax/parser.rb
View
2  lib/google_ajax.rb
@@ -2,7 +2,7 @@
require 'open-uri'
require 'ostruct'
require 'rubygems'
-require 'json'
+require 'json' unless defined? Rails
require 'google_ajax/feed'
require 'google_ajax/language'
View
6 lib/google_ajax/parser.rb
@@ -1,7 +1,11 @@
class GoogleAjax
class Parser
def self.parse(api, method, data)
- data = JSON.parse(data)
+ if defined? Rails
+ data = ActiveSupport::JSON::decode(data)
+ else
+ data = JSON.parse(data)
+ end
Errors.process(data)
parser = Parser::PARSERS[api][method]
parser.process(data['responseData'])
Please sign in to comment.
Something went wrong with that request. Please try again.