python读取json并列_使用多对象python读取json文件

嘿,我是个新手,正在处理JSON文件

我有一个类似这样的JSON文件示例(twitter数据刮取)

这里每个[]包含多个JSON对象,我想从这些对象中提取文本,问题是json.load不能处理多个JSON数组结构([][][])

在下面的示例示例中,第一个[]包含三个JSON对象,第二个包含两个JSON对象[{

"created_at": "2014-12-07 02:17:18",

"favorite_count": 5,

"id_str": "541416129567019008",

"in_reply_to_screen_name": "panellington",

"retweet_count": 15,

"retweeted": false,

"text": "minutes ago. #berkeley #BlackLivesMatter #EricGarner #LAPD"

},

{

"created_at": "2014-12-04 19:21:13",

"favorite_count": 13,

"id_str": "540586640595369984",

"in_reply_to_screen_name": null,

"retweet_count": 38,

"retweeted": false,

"text": "#BlackLivesMatter"

},

{

"created_at": "2014-12-13 00:50:27",

"favorite_count": 1,

"id_str": "543568596299808768",

"in_reply_to_screen_name": null,

"retweet_count": 0,

"retweeted": false,

"text": "MLK Riot is language of unheard #Ferguson #ICantBreathe #BlackLivesMatter"

}]

[{

"created_at": "2015-04-28 13:21:35",

"favorite_count": 0,

"id_str": "593042377658519552",

"in_reply_to_screen_name": null,

"retweet_count": 5,

"retweeted": false,

"text": "RT @fsmith827: A lot of folks speaking against civil unrest have been willfully blind, willfully silent @ #BlackLivesMatter & #PoliceBrutal\u2026",

},

{

"created_at": "2014-12-07 03:17:27",

"favorite_count": 0,

"id_str": "541431264897937408",

"in_reply_to_screen_name": null,

"retweet_count": 456,

"retweeted": false,

"text": "RT @thecrisismag: #ICantBreathe Protesters in Paris march in solidarity with #EricGarner and #MikeBrown #BlackLivesMatter #GrandJury"

}]

我想把它作为JSON对象来读,并想处理这个问题(例如:data[0]['text'])

问题是我的文件包含多个JSON数组对象[一些随机数量的JSON对象],[一些随机数量的JSON对象]等等。。在

^{pr2}$

json.load is not working because of this [][][]... structure## error raised

Error:

raise JSONDecodeError("Extra data", s, end)

JSONDecodeError: Extra data

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值