我很难用jolt转换JSON。这是我的JSON:
{
"totalPages":105,
"firstPage":true,
"lastPage":false,
"numberOfElements":5,
"number":0,
"totalElements":524,
"columns":{
"dimension":{
"id":"variables/evar134",
"type":"string"
},
"columnIds":[
"0",
"1",
"2",
"3",
"5",
"6"
]
},
"rows":[
{
"itemId":"938410065",
"value":"1131568",
"data":[
1.0,
523.0,
0.0,
"NaN",
0.0,
1.0002442201269182
]
},
{
"itemId":"2011836789",
"value":"196149",
"data":[
1.0,
523.0,
0.0,
"NaN",
0.0,
1.0002442201269182
]
},
{
"itemId":"1400165844",
"value":"1258290",
"data":[
1.0,
523.0,
0.0,
"NaN",
0.0,
1.0002442201269182
]
},
{
"itemId":"4260137693",
"value":"1382641",
"data":[
1.0,
523.0,
0.0,
"NaN",
1.0002442201269182,
0.0
]
},
{
"itemId":"4117340671",
"value":"941349",
"data":[
1.0,
523.0,
0.0,
"NaN",
1.0002442201269182,
0.0
]
}
],
"summaryData":{
"totals":[
570.0,
523.0,
506.0,
0.9940711462450593,
482.6580757318888,
35.30252394415497
],
"col-max":[
33.0,
523.0,
2.0,
1.0,
1.0002442201269182,
1.0002442201269182
],
"col-min":[
1.0,
523.0,
1.0,
1.0,
1.0002442201269182,
1.0002442201269182
]
}
}
我想做的只是提取所有“值”数据。例如:
{
"value":"1131568",
},
{
"value":"196149",
}...
我当时认为震动看起来像这样,以拉出每个实例:
[
{
"operation": "shift",
"spec": {
"*": {
"value": "value"
}
}
}
]
但是,当我在jolt validator上尝试此操作时,它表示无效。
有人可以帮我理解如何做吗?
答案 0 :(得分:3)
[
{
"operation": "shift",
"spec": {
"rows": { // here I add key where nested values can be found
"*": {
"value": "[&1].value" // without [&1] all values will be written to the same key
}
}
}
}
]