将json.loads字典输出转换为JSON对象

时间:2018-10-15 17:50:55

标签: python json python-3.x

我正在从如下所示的URL阅读

def findPlace():
    url = "https:myurl.com"
    with urllib.request.urlopen(url) as ur:
        response = ur.read()
    jObj=json.loads(response)
    return jObj

jObj是字典。如何将其转换为JSON对象?我尝试使用json.dump,如下所示:

def findPlace():
        url = "https:myurl.com"
        with urllib.request.urlopen(url) as ur:
            response = ur.read()
        jObj=json.loads(json.dumps(response))
        return jObj

但是它会引发错误TypeError: Object of type 'bytes' is not JSON serializable

有什么建议吗?

0 个答案:

没有答案