class ObjectFramework::HTTP::JSONDecoder
Public Instance Methods
Source
# File lib/object_framework/http/protocol.rb, line 147 def call(body, content_type: nil) return {} if body.empty? raise UnsupportedMediaType unless content_type&.split(";", 2)&.first&.strip&.downcase == "application/json" value = JSON.parse(body.dup.force_encoding(Encoding::UTF_8)) raise InvalidInput, "Expected a JSON object" unless value.is_a?(Hash) value rescue JSON::ParserError, EncodingError raise BadRequest end