src/functions/score_handler.rb
def parse_score(body)
  if body
    begin
      data = JSON.parse(body)
      if data.key?("user_name") and data.key?("score")
        data["score"] = data["score"]
        data["date_time"] = DateTime.now().strftime("%Y-%m-%d %H-%M-%S.%L")
        data
      end
    rescue JSON::ParseError
      nil
    end
  else
    nil
  end
end
# Function for parsing the score in the body
Function for parsing the score in the body
Function for parsing the score in the body
def parse_score(body)
  if body
    begin
      data = JSON.parse(body)
      if data.key?("user_name") and data.key?("score")
        data["score"] = data["score"]
        data["date_time"] = DateTime.now().strftime("%Y-%m-%d %H-%M-%S.%L")
        data
      end
    rescue JSON::ParseError
      nil
    end
  else
    nil
  end
end
def parse_score ( body ) if body begin data = JSON . parse ( body ) if data . key? ( "user_name" ) and data . key? ( "score" ) data [ "score" ] = data [ "score" ] data [ "date_time" ] = DateTime . now ( ) . strftime ( "%Y-%m-%d %H-%M-%S.%L" ) data end rescue JSON :: ParseError nil end else nil end end
Function for parsing the score in the body
Function for parsing the score in the body
body