def json_to_dict(x):
 if (x.find('callback') > (-1)):
  pos_lb = x.find('{')
  pos_rb = x.find('}')
  x = x[pos_lb:(pos_rb + 1)]
 try:
  if (type(x) != str):
   x = x.decode('utf-8')
  return json.loads(x, encoding='utf-8')
 except:
  return x

def json_to_dict ( x ) : if ( x . find ( 'callback' ) > ( - 1 ) ) : pos_lb = x . find ( '{' ) pos_rb = x . find ( '}' ) x = x [ pos_lb : ( pos_rb + 1 ) ] try : if ( type ( x ) != str ) : x = x . decode ( 'utf-8' ) return json . loads ( x , encoding = 'utf-8' ) except : return x
oauthresponse class cant parse the json data with content-type - text/html and because of a rubbish api .