OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/lib/api/utilities/json_gem_parser.rb

12 lines
540 B

# Forces using the classic json gem when parsing.
# This might be beneficial in cases where other parsers, orchestrated by MultiJson misbehave.
# This is e.g. the case with oj which sometimes turns numbers into BigDecimal values.
module API::Utilities::JsonGemParser
def self.call(object, _)
::Grape::Json.load(object, adapter: :json_gem)
rescue ::Grape::Json::ParseError
# handle JSON parsing errors via the rescue handlers or provide error message
raise Grape::Exceptions::InvalidMessageBody, 'application/json'
end
end