Class: Flattr::Response::ParseJson

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/flattr/response/parse_json.rb

Instance Method Summary collapse

Instance Method Details

#parse(body) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/flattr/response/parse_json.rb', line 8

def parse(body)
  case body
  when ''
    nil
  when 'true'
    true
  when 'false'
    false
  else
    begin
      ::MultiJson.decode(body)
    rescue
      nil
    end
  end
end