Method: ContextIO::Response::ParseJson#parse

Defined in:
lib/context-io/response/parse_json.rb

#parse(body) ⇒ Object

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 the response body into JSON

Parameters:

  • The (#to_s)

    response body, containing JSON data.

Returns:

  • (Object)

    The parsed JSON data, probably an Array or a Hash.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/context-io/response/parse_json.rb', line 15

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