我有一个JSON文件
[
{
"api_key": "123123112313121321",
"collaborators_count": 1,
"created_at": "",
"custom_event_fields_used": 0,
"discarded_app_versions": [],
"discarded_errors": [],
"errors_url": "https://api.bugsnag.com/projects/1231231231312/errors",
"events_url": "https://api.bugsnag.com/projects/1231231231213/events",
"global_grouping": [],
"html_url": "https://app.bugsnag.com/lol/kek/",
"id": "34234243224224",
"ignore_old_browsers": true,
"ignored_browser_versions": {},
"is_full_view": true,
"language": "javascript",
"location_grouping": [],
"name": "asdasdaasd",
"open_error_count": 3,
"release_stages": [
"production"
],
"resolve_on_deploy": false,
"slug": "wqeqweqwwqweq",
"type": "js",
"updated_at": "2020-04-06T15:22:10.480Z",
"url": "https://api.bugsnag.com/projects/12312312213123",
"url_whitelist": null
}
]
我需要的是删除除“id:”和“name:”之外的所有行,并保留JSON结构。有人能建议Python或bash脚本来处理这个问题吗
您可以尝试以下方法:
与
jq
一起:使用python,您可以首先用^{} 反序列化JSON文件(对象的JSON数组),然后用列表过滤出所需的键:
输出:
如果要将此python列表序列化为另一个输出文件,可以使用^{} :
output.json
相关问题 更多 >
编程相关推荐