源JSON:
[
{
"other": false,
"granularity": [
{
"impressions": 15,
"date": "2021-11-02"
},
{
"impressions": 67,
"date": "2021-11-03"
}
],
"metadata": {
"adGroupId": 5792423,
"startTime": "2021-06-29T21:00:00.000"
}
},
{
"other": false,
"granularity": [
{
"impressions": 226,
"date": "2021-11-02"
},
{
"impressions": 2339,
"date": "2021-11-03"
}
],
"metadata": {
"adGroupId": 578101600,
"startTime": "2021-06-29T08:05:52.176"
}
}
]
我尝试了这个规范:
[
{
"operation": "shift",
"spec": {
"*": {
"granularity": {
"*": "[&2].&"
},
"metadata": {
"adGroupId": "[&2].adGroupId"
}
}
}
}
]
结果:
[
{
"0": {
"impressions": 15,
"date": "2021-11-02"
},
"1": {
"impressions": 67,
"date": "2021-11-03"
},
"adGroupId": 5792423
},
{
"0": {
"impressions": 226,
"date": "2021-11-02"
},
"1": {
"impressions": 2339,
"date": "2021-11-03"
},
"adGroupId": 578101600
}
]
我想删除这些索引0,1,...etc
从顶层。和adGroupId
应该在每一行。
所以我期待这个结果:
[
{
"impressions": 15,
"date": "2021-11-02",
"adGroupId": 5792423
},
{
"impressions": 67,
"date": "2021-11-03",
"adGroupId": 5792423
},
{
"impressions": 226,
"date": "2021-11-02",
"adGroupId": 578101600
},
{
"impressions": 2339,
"date": "2021-11-03",
"adGroupId": 578101600
}
]
如何修复?谢谢!
1条答案
按热度按时间r6l8ljro1#
您可以收集
granularity
键下的键-值对,同时以[&3].&1.
作为子键的前缀,以便通过向上三个级别选择公共索引,然后在最后一步删除索引的键,例如