Switch to Oj for JSON parsing.
authorWard Vandewege <ward@clinicalfuture.com>
Mon, 4 Feb 2013 14:50:57 +0000 (09:50 -0500)
committerWard Vandewege <ward@clinicalfuture.com>
Mon, 4 Feb 2013 14:50:57 +0000 (09:50 -0500)
Gemfile
Gemfile.lock
app/controllers/application_controller.rb
app/controllers/orvos/v1/links_controller.rb

diff --git a/Gemfile b/Gemfile
index 9d4fc15a977314b065029678be4e30409a83b2eb..c60bf9f7701210724c2df1063ddeddd55ebbd498 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -8,7 +8,7 @@ gem 'rails', '3.1.10'
 #gem 'sqlite3'
 gem 'pg'
 
-gem 'json'
+gem 'oj'
 
 # Gems used only for assets and not required
 # in production environments by default.
index 11878f2df72727df5832c32d09be777db5ec3fef..e78e65692e14c14421dd75c00e4b3daa2a6d32aa 100644 (file)
@@ -87,6 +87,7 @@ GEM
       jwt (~> 0.1.4)
       multi_json (~> 1.0)
       rack (~> 1.2)
+    oj (2.0.3)
     omniauth (1.1.1)
       hashie (~> 1.2)
       rack
@@ -160,7 +161,7 @@ DEPENDENCIES
   acts_as_api
   coffee-rails (~> 3.1.1)
   jquery-rails
-  json
+  oj
   omniauth (= 1.1.1)
   omniauth-oauth2 (= 1.1.1)
   passenger
index 076e3f868e8ee2bef1b13359cf398bcc037968e3..d3427160cbbfd249476264441f4ec58f4a1199ee 100644 (file)
@@ -56,7 +56,7 @@ class ApplicationController < ActionController::Base
             current_user.uuid, current_user.uuid)
     if params[:where]
       where = params[:where]
-      where = JSON.parse(where) if where.is_a?(String)
+      where = Oj.load(where) if where.is_a?(String)
       conditions = ['1=1']
       where.each do |attr,value|
         if (!value.nil? and
@@ -98,7 +98,7 @@ class ApplicationController < ActionController::Base
       raise "no #{resource_name} (or #{resource_name.camelcase(:lower)}) provided with request #{params.inspect}"
     end
     if @attrs.class == String
-      @attrs = uncamelcase_hash_keys(JSON.parse @attrs)
+      @attrs = uncamelcase_hash_keys(Oj.load @attrs)
     end
     @object = model_class.new @attrs
     @object.save
@@ -108,7 +108,7 @@ class ApplicationController < ActionController::Base
   def update
     @attrs = params[resource_name]
     if @attrs.is_a? String
-      @attrs = uncamelcase_hash_keys(JSON.parse @attrs)
+      @attrs = uncamelcase_hash_keys(Oj.load @attrs)
     end
     @object.update_attributes @attrs
     show
@@ -191,7 +191,7 @@ class ApplicationController < ActionController::Base
   def accept_attribute_as_json(attr, force_class)
     if params[resource_name].is_a? Hash
       if params[resource_name][attr].is_a? String
-        params[resource_name][attr] = JSON.parse params[resource_name][attr]
+        params[resource_name][attr] = Oj.load params[resource_name][attr]
         if force_class and !params[resource_name][attr].is_a? force_class
           raise TypeError.new("#{resource_name}[#{attr.to_s}] must be a #{force_class.to_s}")
         end
index e5177092e13c938a289f4e6af81d9190039f24c6..046f6838f27851df2add5dd975016c1c42a4fa1c 100644 (file)
@@ -1,7 +1,7 @@
 class Orvos::V1::LinksController < ApplicationController
   def index
     if params[:tail_uuid]
-      params[:where] = JSON.parse(params[:where]) if params[:where].is_a?(String)
+      params[:where] = Oj.load(params[:where]) if params[:where].is_a?(String)
       params[:where] ||= {}
       params[:where][:tail_uuid] = params[:tail_uuid]
     end