2007-12-21 08:48:59 +01:00
|
|
|
module ActiveResource
|
|
|
|
module Formats
|
|
|
|
module JsonFormat
|
|
|
|
extend self
|
2008-09-07 07:54:05 +02:00
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
def extension
|
|
|
|
"json"
|
|
|
|
end
|
2008-09-07 07:54:05 +02:00
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
def mime_type
|
|
|
|
"application/json"
|
|
|
|
end
|
2008-09-07 07:54:05 +02:00
|
|
|
|
|
|
|
def encode(hash, options={})
|
2008-10-27 07:47:01 +01:00
|
|
|
hash.to_json(options)
|
2007-12-21 08:48:59 +01:00
|
|
|
end
|
2008-09-07 07:54:05 +02:00
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
def decode(json)
|
|
|
|
ActiveSupport::JSON.decode(json)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2008-09-07 07:54:05 +02:00
|
|
|
end
|