I am having issues to create a Jolt specification for the following input, I want to convert the Score to an array called Scores, what is happening is when I have only one score it is not send as array, so I want to convert to an array of scores.
[
{
"Page": 320301,
"ScoreInfo": {
"StadiumID": 126,
"Stadium": "abcded",
"Inn": 3,
"TB": 2,
"Team": [
{
"HV": 1,
"ID": 1,
"NameS": "abdcd",
"NameES": "abdcd",
"R": 1,
"PA": 10,
"H": 2,
"BB": 3,
"SB": 0,
"E": 0,
"Score": {
"Inn": 1,
"TB": 2,
"R": 0,
"H": 0,
"BB": 1
}
},
{
"HV": 2,
"ID": 3,
"NameS": "afewqe",
"NameES": "dadfa",
"R": 1,
"PA": 12,
"H": 3,
"BB": 0,
"SB": 0,
"E": 0,
"Score": [
{
"Inn": 1,
"TB": 1,
"R": 1,
"H": 2,
"BB": 0
},
{
"Inn": 2,
"TB": 1,
"R": 0,
"H": 0,
"BB": 0
}
]
}
],
"HV": null
}
}
]
The output expected is:
{
"ScoreInfo" : {
"Team" : [ {
"HV" : 1,
"ID" : 1,
"NameS" : "abdcd",
"NameES" : "abdcd",
"R" : 1,
"PA" : 10,
"H" : 2,
"BB" : 3,
"SB" : 0,
"E" : 0,
"Scores" : [ {
"Inn" : 1,
"TB" : 2,
"R" : 0,
"H" : 0,
"BB" : 1
} ]
}, {
"HV" : 2,
"ID" : 3,
"NameS" : "afewqe",
"NameES" : "dadfa",
"R" : 1,
"PA" : 12,
"H" : 3,
"BB" : 0,
"SB" : 0,
"E" : 0,
"Scores" : [ {
"Inn" : 1,
"TB" : 1,
"R" : 1,
"H" : 2,
"BB" : 0
}, {
"Inn" : 2,
"TB" : 1,
"R" : 0,
"H" : 0,
"BB" : 0
}]
} ]
},
"Type" : "ScoreInfo",
"Datasource" : "Vendor"
}
I have tried it so far, but it is not going anywhere:
[
{
"operation": "shift",
"spec": {
"*": {
"ScoreInfo": {
"Team": {
"*": {
"@": "ScoreInfo.&2",
"Score": {
"*": {
"@": "ScoreInfo.Team.Scores.[]"
}
}
}
}
}
}
}
},
{
"operation": "default",
"spec": {
"Datasource": "Vendor",
"Type": "ScoreInfo"
}
}
]
Thanks in advance,
