我试图阅读元素的值。 出于测试目的,我试图读取account_name元素值。
我试过这个
jsonloop query = "data/ads/data/insights/data[*]"
account_name = "$.data.ads.data.insights.data.[*].account_name"
但没有得到结果。除此之外,我用谷歌搜索了很多,我的逻辑似乎没问题。但我不知道哪里出错了。
{
"data": [{
"id": "act_78425484545145418"
}, {
"id": "act_87814545415645416"
}, {
"ads": {
"data": [{
"insights": {
"data": [{
"account_name": "Emirates WW",
"campaign_name": "FR_Ozone_aug",
"adset_name": "Android",
"ad_name": "C_mail_9sept",
"spend": 12.2,
"impressions": "1146",
"clicks": "16",
"_store_clicks": "0",
"inline_click_pointss": "16",
"actions": [{
"action_type": "custom_event._activate_",
"value": 2
}, {
"action_type": "custom_event.other",
"value": 1
}, {
"action_type": "click_points",
"value": 16
}, {
"action_type": "__install",
"value": 1
}, {
"action_type": "offsite_points.view_content_points",
"value": 25
}, {
"action_type": "post_points",
"value": 16
}, {
"action_type": "post_points",
"value": 16
}, {
"action_type": "offsite_points",
"value": 25
}, {
"action_type": "custom_event",
"value": 3
}],
"date_start": "2016-09-09",
"date_stop": "2016-09-19"
}],
"paging": {
"cursors": {
"before": "ADZZZZ",
"after": "ADZZZZ"
}
}
},
"id": "6054027758549"
}, {
"insights": {
"data": [{
"account_name": "Emirates WW",
"campaign_name": "FR_Ozone_aug",
"adset_name": "Reta_Phy_iOS",
"ad_name": "Council_email_9sept",
"spend": 10.13,
"impressions": "1004",
"clicks": "10",
"_store_clicks": "8",
"inline_click_pointss": "10",
"actions": [{
"action_type": "click_points",
"value": 10
}, {
"action_type": "offsite_points.view_content_points",
"value": 38
}, {
"action_type": "post_points",
"value": 10
}, {
"action_type": "post_points",
"value": 10
}, {
"action_type": "offsite_points",
"value": 38
}],
"date_start": "2016-09-09",
"date_stop": "2016-09-19"
}],
"paging": {
"cursors": {
"before": "ADZZZZ",
"after": "ADZZZZ"
}
}
},
"id": "6054030075149"
}],
"paging": {
"cursors": {
"before": "Juysubgysbyy",
"after": "Nhwunhseuubeyegb"
}
}
}
}]
}
有人可以帮忙吗?
先谢谢!!
答案 0 :(得分:0)
第一个和第二个 data
属性具有数组值,因此您应该在它们之后添加 .[*]
:
account_name = "$.data.[*].ads.data.[*].insights.data.[*].account_name"
结果:
[
"Emirates WW",
"Emirates WW"
]