尝试在 Python 中打开 JSON 文件时出现 JSONDecodeError

时间:2021-03-05 12:12:35

标签: python json

我从 Twitter 上的抓取内容获得了以下 JSON 文件:

{"id": 911265668921733120, 
"conversation_id": "911265668921733120",
"created_at": "2017-09-22 19:27:20 EAT", 
"date": "2017-09-22",
"time": "19:27:20",
"timezone": "+0300", 
"user_id": 61177265, 
"username": "sircalic", 
"name": "Dan",
"place": {"type": "Point", 
"coordinates": [-1.18998912, 36.77644171]},
"tweet": "Bitcoin ain't stabilizing at $4,500 any time soon LOL but it's good to stock for long term.", 
"language": "en", 
"mentions": [],
"urls": [], 
"photos": [],
"replies_count": 0,
"retweets_count": 0,
"likes_count": 0,
"hashtags": [],
"cashtags": [],
"link": "https://twitter.com/sircalic/status/911265668921733120",
"retweet": false,
"quote_url": "",
"video": 0,
"thumbnail": "",
"near": "Nairobi", 
"geo": "", 
"source": "",
"user_rt_id": "",
"user_rt": "",
"retweet_id": "",
"reply_to": [],
"retweet_date": "", 
"translate": "", 
"trans_src": "",
"trans_dest": ""
}

但是当我尝试使用以下代码在 Python 中打开它时:

current_file = str(os.getcwd()) + '/NewYork2017-09-30 00:00:00.json'
l = json.load(open(current_file))

我收到以下错误:

JSONDecodeError: Extra data: line 2 column 1 (char 1036)

我对该错误进行了一些研究,但我不断收到错误消息,即字符有问题,但我似乎找不到解决方案。

有什么办法可以修复它吗?

0 个答案:

没有答案