@@ -6,6 +6,7 @@ require 'digest/md5'
require 'base64'
require 'active_resource/connection_ext'
require 'shopify_api/limits'
+require 'shopify_api/json_format'
module ShopifyAPI
include Limits
@@ -0,0 +1,23 @@
+module ActiveResource
+ class Base
+ def encode(options = {})
+ same = dup
+ same.attributes = {self.class.element_name => same.attributes} if self.class.format.extension == 'json'
+
+ same.send("to_#{self.class.format.extension}", options)
+ end
+ module Formats
+ module JsonFormat
+ def decode(json)
+ data = ActiveSupport::JSON.decode(json)
+ if data.is_a?(Hash) && data.keys.size == 1
+ data.values.first
+ else
+ data
+end
@@ -1,5 +1,6 @@
class Base < ActiveResource::Base
extend Countable
+ self.include_root_in_json = false
end