Class: Hanami::Routing::Parsing::JsonParser Private

Inherits:
Parser
  • Object
show all
Defined in:
lib/hanami/routing/parsing/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:

  • 0.2.0

Instance Method Summary collapse

Methods inherited from Parser

for

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:

  • 0.2.0



11
12
13
# File 'lib/hanami/routing/parsing/json_parser.rb', line 11

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:

  • 0.2.0



25
26
27
28
29
# File 'lib/hanami/routing/parsing/json_parser.rb', line 25

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