这是我想定义的规则格式
[
{
"field_title":"目标"
"field_value":"data.data.items[].target"
},
{
"field_title":"日期"
"field_value":"data.data.items[].display_date"
},
{
"field_title":"总数"
"field_value":"data.data.total"
},
]
通过上面的字段定义,因为要导出excel,所以得有字段映射,才能动态把mongodb的数据按规则转换成xlsx表格数据,具体转换代码我如何写?以下是mongodb 类似json的数据
{
"_id": {
"$oid": "66d58a4ffd7ece5c431a26ee"
},
"status_id": 161971,
"batch_id": 2,
"data": {
"data": {
"total": 66,
"items": [
{
"target": "mediamarkt.at",
"display_date": "2024-07-01",
"device_type": "all",
"geo": "at",
"traffic": 4201438,
"traffic_share": 0.85597244,
"users": 1684488,
"users_share": 0.79552782,
"users_mobile_share": 0.76009031,
"users_desktop_share": 0.23990969,
"avg_visit_duration": 474,
"bounce_rate": 0.609,
"pages_per_visit": 2.7819,
"desktop_share": 0.26375541,
"mobile_share": 0.73624459
}
]
},
"status": 0
},
"seed_id": 81,
"status": 0
}