我正在尝试从此深度嵌套的json结构创建一个csv文件:
{
"id": "12345678",
"name": "BOOGIEMAN",
"account_id": "1234567",
"campaign_id": "123",
"attribution_spec": [
{
"event_type": "CLICK_THROUGH",
"window_days": 1
}
],
"bid_amount": 14000,
"bid_info": {
"REACH": 14000
},
"bid_strategy": "LOWEST_COST_WITH_BID_CAP",
"pacing_type": [
"standard"
],
"promoted_object": {
"application_id": "123456",
"custom_event_type": "PURCHASE",
"object_store_url": "https://itunes.apple.com/app/123456"
},
"recurring_budget_semantics": true,
"review_feedback": "[]",
"source_adset": {
"id": "1234567"
},
"source_adset_id": "1234567",
"start_time": "2019-12-12T17:10:20+0100",
"status": "ACTIVE",
"targeting": {
"age_max": 65,
"age_min": 20,
"custom_audiences": [
{
"id": "1234567",
"name": "SAMPLE_NAME"
}
],
"exclusions": {
"interests": [
{
"id": "123",
"name": "Teens Fashion"
},
{
"id": "456",
"name": "Boomerang (TV channel)"
},
{
"id": "7895",
"name": "Boomerang"
},
{
"id": "123",
"name": "Nickelodeon Games and Sports for Kids"
},
{
"id": "555",
"name": "Disney Interactive"
},
{
"id": "123123",
"name": "Disney Channel"
},
{
"id": "6456",
"name": "CBBC (TV channel)"
},
{
"id": "124124",
"name": "Nickelodeon"
},
{
"id": "34653254",
"name": "Cartoon Network"
},
{
"id": "12414",
"name": "The Children's Channel"
},
{
"id": "325623",
"name": "International Children's Games"
},
{
"id": "325234",
"name": "Children's television series"
},
{
"id": "6324535",
"name": "Teens Only ღ"
},
{
"id": "6013742415695",
"name": "Books for Kids"
}
]
},
"targeting_optimization": "none",
"user_device": [
"iPad",
"iPhone"
],
"user_os": [
"iOS_ver_9.0_and_above"
]
},
"updated_time": "2019-12-20T13:04:20+0100",
"use_new_app_click": false
}
我尝试使用Pandas for Python库,并且能够将数据解压缩到1级,但是我想尽可能地解压缩此数据,以便没有任何列表或对象。
我想这个问题更多地围绕着处理像这样的数据的最佳实践是什么?
我个人只是使用csv库。 https://docs.python.org/3.8/library/csv.html
这里有一篇详细的文章说明了在这种情况下的用法。http://blog.appliedinformaticsinc.com/how-to-parse-and-convert-json-to-csv-using-python/