lib/restfully/parsing.rb in restfully-0.2.3 vs lib/restfully/parsing.rb in restfully-0.3.0
- old
+ new
@@ -7,21 +7,21 @@
class ParserNotFound < Restfully::Error; end
def unserialize(object, options = {})
content_type = options[:content_type]
content_type ||= object.headers['Content-Type'] if object.respond_to?(:headers)
case content_type
- when /^application\/json/i
+ when /^application\/.*?json/i
JSON.parse(object)
else
raise ParserNotFound.new("Content-Type '#{content_type}' is not supported. Cannot parse the given object.")
end
end
def serialize(object, options = {})
content_type = options[:content_type]
content_type ||= object.headers['Content-Type'] if object.respond_to?(:headers)
case content_type
- when /^application\/json/i
+ when /^application\/.*?json/i
JSON.dump(object)
else
raise ParserNotFound, [object, content_type]
end
end
\ No newline at end of file