Class: Hanami::Middleware::BodyParser::JsonParser Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/middleware/body_parser/json_parser.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 1.3.0

Instance Method Summary collapse

Instance Method Details

#mime_typesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.3.0



12
13
14
# File 'lib/hanami/middleware/body_parser/json_parser.rb', line 12

def mime_types
  ['application/json', 'application/vnd.api+json']
end

#parse(body) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parse a json string

Parameters:

  • body (String)

    a json string

Returns:

  • (Hash)

    the parsed json

Raises:

Since:

  • 1.3.0



26
27
28
29
30
# File 'lib/hanami/middleware/body_parser/json_parser.rb', line 26

def parse(body)
  Hanami::Utils::Json.parse(body)
rescue Hanami::Utils::Json::ParserError => e
  raise BodyParsingError.new(e.message)
end