mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
26 lines
427 B
Ruby
26 lines
427 B
Ruby
require 'active_support/json'
|
|
|
|
module ActiveResource
|
|
module Formats
|
|
module JsonFormat
|
|
extend self
|
|
|
|
def extension
|
|
"json"
|
|
end
|
|
|
|
def mime_type
|
|
"application/json"
|
|
end
|
|
|
|
def encode(hash, options = nil)
|
|
ActiveSupport::JSON.encode(hash, options)
|
|
end
|
|
|
|
def decode(json)
|
|
Formats.remove_root(ActiveSupport::JSON.decode(json))
|
|
end
|
|
end
|
|
end
|
|
end
|