我試圖找到一個產生所需輸出的規范陣列
輸入:
{
"aggregations": {
"masterId": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "1Q52",
"doc_count": 3,
"serialNumbers": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "3R24Z3",
"count": 1
},
{
"key": "526GA2",
"count": 1
},
{
"key": "873XHE",
"count": 1
}
]
}
}
]
}
}
}
規格:試圖弄清楚這一點
期望輸出:
{
"1Q52": ["3R24Z3", "526GA2", "873XHE"]
}
我目前的規格陣列是
[
{
"operation": "shift",
"spec": {
"aggregations": {
"masterId": {
"buckets": {
"*": {
"key": "key",
"serialNumbers": {
"buckets": {
"*": {
"key": "key"
}
}
}
}
}
}
}
}
}
]
我目前的輸出是
{
"key" : [ "1Q52", "3R24Z3", "526GA2", "873XHE" ]
}
什么樣的規格陣列可以給我想要的輸出?
uj5u.com熱心網友回復:
您可以向上 4 級并使用"key": "@(4,key)"例如獲取值作為陣列的鍵
[
{
"operation": "shift",
"spec": {
"aggregations": {
"masterId": {
"buckets": {
"*": {
"serialNumbers": {
"buckets": {
"*": {
"key": "@(4,key)"
}
}
}
}
}
}
}
}
}
]
其中:,然后{計算三重字符遍歷以達到所需的鍵值。

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/383819.html
