从 XHR-response 在 Python 中展平 json

问题描述

更新:之前的 XHR 响应不正确

我未能以正确的方式从 XHR 响应中展平我的 json。 我刚刚扩展了下面的一项,以使其更具可读性。

我正在使用 python 并尝试过,但结果不正确。

u = "URL"
SE_units = requests.get(u,headers=h).json()
dp = pd.json_normalize(SE_units,[SE_units,"Items"])
SE_dp_list.append(dp)

从下面的 XHR-Response 中,我想将 Items-information 转换为 CSV,但是当我执行 export.to_CSV 时,我发现它没有正确展平

{"Content":{
"PaginationCount":12,"FilterValues":null,"Items":
[{
    "Id":258370,"OriginalType":"BostadobjectPage","PublishDate":null,"Title":"02 Skogsvagen","Image":
    {
        "description":null,"alt":null,"externalUrl":"/abc.jpg"
    },"StaticMapImage":null,"Url":"/abcd/","HideReadMore":false,"ProjectData":null,"ObjectData":
    {
        "BuildingTypeLabel":"Rad-/Kedje-/Parhus","ObjectStatus":"SalesInProgress","ObjectStatusLabel":"Till salu","ObjectNumber":"02","City":"staden","RoomInterval":"2-3","LivingArea":"101","SalesPrice":"2 150 000","MonthlyFee":null,"Elevator":false,"Balcony":false,"Terrace":true
    },"FastighetProjectData":null,"FastighetobjectData":null,"OfficeData":null
},{
    "Id":258372,....."same structure as above"
    "OfficeData":null
}],"noresultsMessage":null,"SimplifiedBuildingType":null,"NextIndex":-1,"TotalCount":12,"heading":null,"ShowMoreLabel":null,"DataColumns":null,"Error":null},"ObjectSearchData":
{
    "BuildingVariantId":"Houses","BuildingsFoundLabel":" {count}","BuildingTypeIds":[400],"BuildingsAvailableForSale":12,"BuildingnoresultsLabel":""
}

}

写入 CSV 后的预期输出格式

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)