什么样的 JSON JOLT 规范来获得键值输出,其中键是数据值,值是数组
What kind of JSON JOLT Spec to get key-value output where key is a data value and value is an array
我正在尝试找到产生所需输出的规范数组
输入:
{
"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" ]
}
什么样的规格数组可以给我想要的输出?
你可以向上 4 级并使用 "key": "@(4,key)"
获取值作为数组的键,例如
[
{
"operation": "shift",
"spec": {
"aggregations": {
"masterId": {
"buckets": {
"*": {
"serialNumbers": {
"buckets": {
"*": {
"key": "@(4,key)"
}
}
}
}
}
}
}
}
}
]
其中 :
然后计算三次 {
字符遍历以达到所需的键值。
我正在尝试找到产生所需输出的规范数组
输入:
{
"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" ]
}
什么样的规格数组可以给我想要的输出?
你可以向上 4 级并使用 "key": "@(4,key)"
获取值作为数组的键,例如
[
{
"operation": "shift",
"spec": {
"aggregations": {
"masterId": {
"buckets": {
"*": {
"serialNumbers": {
"buckets": {
"*": {
"key": "@(4,key)"
}
}
}
}
}
}
}
}
}
]
其中 :
然后计算三次 {
字符遍历以达到所需的键值。