Parsing Json to active record

I want to take some elements from json string from facebook {“algorithm”:“HMAC-SHA256”,“expires”:1355720400,“issued_at”:1355715753,“oauth_token”:“AAAAAChvQA2sBAClBE0B40nw7YqrAuYNhOZCYJ4sZAMSZC8VFZAz81s2mndYbS7t2DxTzFkQ88FmXsyBzznuQUuu1p2htZBav5KQmD3ICIcwZDZD”,“user”:{“country”:“us”,“locale”:“en_US”,“age”:{“min”:21}},“user_id”:“527477320”} and put them in a active record .

Can anyone help me a good way to do it?

Code->

class ApplicationController < ActionController::Base
before_filter :check_uri

protect_from_forgery

def check_uri
@signed_request_json = decode_data(params[:signed_request]).to_json
end

def base64_url_decode str
encoded_str = str.gsub(’-’,’+’).gsub(’_’,’/’)
encoded_str += ‘=’ while !(encoded_str.size % 4).zero?
Base64.decode64(encoded_str)
end

def decode_data str
encoded_sig, payload = str.split(’.’)
data = ActiveSupport::JSON.decode base64_url_decode(payload)
end

end

I want to take some elements from json string from facebook {“algorithm”:“HMAC-SHA256”,“expires”:1355720400,“issued_at”:1355715753,“oauth_token”:“AAAAAChvQA2sBAClBE0B40nw7YqrAuYNhOZCYJ4sZAMSZC8VFZAz81s2mndYbS7t2DxTzFkQ88FmXsyBzznuQUuu1p2htZBav5KQmD3ICIcwZDZD”,“user”:{“country”:“us”,“locale”:“en_US”,“age”:{“min”:21}},“user_id”:“527477320”} and put them in a active record .

Can anyone help me a good way to do it?

Code->

class ApplicationController < ActionController::Base
before_filter :check_uri

protect_from_forgery

def check_uri
@signed_request_json = decode_data(params[:signed_request]).to_json
end

def base64_url_decode str
encoded_str = str.gsub(’-’,’+’).gsub(’_’,’/’)
encoded_str += ‘=’ while !(encoded_str.size % 4).zero?
Base64.decode64(encoded_str)
end

def decode_data str
encoded_sig, payload = str.split(’.’)
data = ActiveSupport::JSON.decode base64_url_decode(payload)
end

end