Class: JsonParser

Inherits:
Lotus::Routing::Parsing::Parser
  • Object
show all
Defined in:
lib/quiver/json_parser.rb

Instance Method Summary collapse

Instance Method Details

#mime_typesObject



2
3
4
# File 'lib/quiver/json_parser.rb', line 2

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

#parse(body) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/quiver/json_parser.rb', line 6

def parse(body)
  parsed = JSON.parse(body)

  if parsed.is_a?(Array)
    { request_data: parsed }
  else
    parsed
  end
rescue JSON::ParserError => e
  {terrible_hack: e}
end