Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

540 B
Raw Blame
# 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