我想创建一个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、名称和时区包括到每个对象中。
我昨天试了一整天,有很多不同的规格,但没有一个能给我我需要的输出。
目前我有以下规格:
[
{
"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
}
...
我怎样才能做到这一点?为什么他把所有东西都添加到一个数组中,而不是创建单独的对象?如果有任何帮助,我将不胜感激。