我正在准备颠簸说明书,但我无法完成它,请帮助。
**注意:**有一个credits数组,该数组的值需要Map到schema字段,schema字段的类型为creditrecord。
输入:
{
"schema": {
"fields": [
{
"name": "user",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "billed",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "currency",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "currency_conversion_rate",
"type": "FLOAT",
"mode": "NULLABLE"
},
{
"name": "usage_unit",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "adjustment_info_mode",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "adjustment_info_type",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "InvoiceMonth",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "credits",
"type": "RECORD",
"mode": "REPEATED",
"fields": [
{
"name": "name",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "amount",
"type": "FLOAT",
"mode": "NULLABLE"
},
{
"name": "full_name",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "id",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "type",
"type": "STRING",
"mode": "NULLABLE"
}
]
},
{
"name": "resource_name",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "resource_global_name",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "label",
"type": "STRING",
"mode": "NULLABLE"
}
]
},
"InvoiceMonth": "202006",
"credits": [
{
"v": {
"f": [
{
"v": "ae391_credit:0"
},
{
"v": "-0.010237"
},
{
"v": "Committed dollar "
},
{
"v": "ae31_credit:0"
},
{
"v": "COMMITTED_BASE"
}
]
}
},
{
"v": {
"f": [
{
"v": "ae391_credit:0"
},
{
"v": "-0.010237"
},
{
"v": "Committed dollar "
},
{
"v": "ae31_credit:0"
},
{
"v": "COMMITTED_BASE"
}
]
}
}
],
"resource_name": "projects-0",
"resource_global_name": "//compute.googleapis.com/",
"label": ""
}
我试过这种震动:
[
{
"operation": "shift",
"spec": {
"credits": {
"*": {
"*": {
"*": {
"*": {
"@v": "[&3].@(5,schema.fields.fields[&].name)"
}
}
}
}
}
}
}
]
预期输出:
[
{
"name": "ae391_credit:0",
"amount": "-0.010237",
"full_name": "Committed dollar",
"id": "ae31_credit:0",
"type": "COMMITTED_BASE"
},
{
"name": "ae391_credit:0",
"amount": "-0.010237",
"full_name": "Committed dollar",
"id": "ae31_credit:0",
"type": "COMMITTED_BASE"
}
]
1条答案
按热度按时间vmpqdwk31#
您可以使用
shift
操作,并将内部fields
向上移动,然后使用另一个移位来获取名称的值作为credits
数组中的键。