src/functions/questions_handler.rb
# Function for parsing the body in a HTTP response
Function for parsing the body in a HTTP response
Function for parsing the body in a HTTP response
def parse_body(body)
  if body
    begin
      data = JSON.parse(body)
      if data.key?('ID') and data.key?('answer') and data.key?('options') and data.key?('question')
        data['ID'] = data['ID'].strip.to_i
        data
      else
        nil
      end
    rescue JSON::ParseError
      nil
    end
  else
    nil
  end
end
def parse_body ( body ) if body begin data = JSON . parse ( body ) if data . key? ( 'ID' ) and data . key? ( 'answer' ) and data . key? ( 'options' ) and data . key? ( 'question' ) data [ 'ID' ] = data [ 'ID' ] . strip . to_i data else nil end rescue JSON :: ParseError nil end else nil end end
Function for parsing the body in a HTTP response
Function for parsing the body in a HTTP response
body