import requests
import time


def request_url_json(url: str) -> dict:
  """Get JSON object version of reponse to GET request to given URL.

  Args:
    url: URL to make the GET request.

  Returns:
    JSON decoded response from the GET call.
      Empty dict is returned in case the call fails.
  """
  print(url)
  try:
    req = requests.get(url)
    # print(req.url)
  except requests.exceptions.ReadTimeout:
    print('Timeout occoured, retrying after 10s.')
    time.sleep(10)
    try:
      req = requests.get(url)
    except requests.exceptions.ReadTimeout:
      print('Timeout occoured, request failed.')
      return {}

  if req.status_code == requests.codes.ok:
    response_data = req.json()
  else:
    response_data = {'http_err_code': req.status_code}
    print('HTTP status code: ' + str(req.status_code))
  return response_data