From b8b512468a728f597479a2a8249eb8bc5138088b Mon Sep 17 00:00:00 2001
From: Galvin Hsiu <galvin.hsiu@gmail.com>
Date: Sat, 28 Jan 2012 11:27:19 -0800
Subject: [PATCH] Fix for parse_raw_data -- json parse catches invalid json and
 activesupport::json needs to be caught.

---
 lib/geocoder/lookups/base.rb | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/geocoder/lookups/base.rb b/lib/geocoder/lookups/base.rb
index cbf3f828..838f633c 100644
--- a/lib/geocoder/lookups/base.rb
+++ b/lib/geocoder/lookups/base.rb
@@ -120,14 +120,14 @@ module Geocoder
       # Parses a raw search result (returns hash or array).
       #
       def parse_raw_data(raw_data)
-        if defined?(ActiveSupport::JSON)
-          ActiveSupport::JSON.decode(raw_data)
-        else
-          begin
+        begin
+          if defined?(ActiveSupport::JSON)
+            ActiveSupport::JSON.decode(raw_data)
+          else
             JSON.parse(raw_data)
-          rescue
-            warn "Geocoding API's response was not valid JSON."
           end
+        rescue
+          warn "Geocoding API's response was not valid JSON."
         end
       end
 
-- 
GitLab