我想创建一个JOLT规范,过滤掉我需要的一切.
我有这个JSON输入:
{
"StationDataList": {
"StationData": {
"ChannelData": [
{
"Values": {
"VT": [
{
"t": "2023-12-13T00:15:00",
"content": -1
},
{
"t": "2023-12-13T00:30:00",
"content": -2
},
{
"t": "2023-12-13T00:45:00",
"content": -3
}
]
},
"channelId": "channelId1"
},
{
"Values": {
"VT": [
{
"t": "2023-12-13T01:00:00",
"content": 1
},
{
"t": "2023-12-13T02:00:00",
"content": 2.5
},
{
"t": "2023-12-13T03:00:00",
"content": 3
}
]
},
"channelId": "channelId2"
}
],
"timezone": "+01:00",
"name": "stationName",
"stationId": "123"
}
}
}
我想把每个VT对象提取成单独的对象,并在每个对象中包含stationId、channelId、name和timezone字段.
我昨天试了一整天,有很多不同的规格,但没有一个给我所需要的输出. 目前我有这个规格:
[
{
"operation": "shift",
"spec": {
"StationDataList": {
"StationData": {
"ChannelData": {
"*": {
"Values": {
"VT": {
"*": {
"@(5,stationId)": "[&4].stationId",
"@(5,timezone)": "[&4].timezone",
"@(5,name)": "[&4].name",
"@(3,channelId)": "[&4].channelId",
"t": "[&4].t",
"content": "[&4].content"
}
}
}
}
}
}
}
}
}
]
它返回了这个输出:
[
{
"stationId" : [ "123", "123", "123" ],
"timezone" : [ "+01:00", "+01:00", "+01:00" ],
"name" : [ "stationName", "stationName", "stationName" ],
"channelId" : [ "channelId1", "channelId1", "channelId1" ],
"t" : [ "2023-12-13T00:15:00", "2023-12-13T00:30:00", "2023-12-13T00:45:00" ],
"content" : [ -1, -2, -3 ]
},
{
"stationId" : [ "123", "123", "123" ],
"timezone" : [ "+01:00", "+01:00", "+01:00" ],
"name" : [ "stationName", "stationName", "stationName" ],
"channelId" : [ "channelId2", "channelId2", "channelId2" ],
"t" : [ "2023-12-13T01:00:00", "2023-12-13T02:00:00", "2023-12-13T03:00:00" ],
"content" : [ 1, 2.5, 3 ]
}
]
但我希望它们都是独立的对象,而不是所有在一个数组中,就像:
{
"stationId" : "123",
"timezone" : "+01:00",
"name" : "stationName",
"channelId" : "channelId1",
"t" : "2023-12-13T00:15:00",
"content" : -1
},
{
"stationId" : "123",
"timezone" : "+01:00",
"name" : "stationName",
"channelId" : "channelId1",
"t" : "2023-12-13T00:30:00",
"content" : -2
}
...
我怎么能做到呢?为什么他要把所有东西都添加到数组中,而不是创建单独的对象?我会很感激你的帮助.