I am trying to achieve this expected output using jolt transform, can anyone pls help me out.
input:
{
"users": [
{
"username": "user1",
"password": "password1",
"privacy_password": "privacy1",
"engineId": "8000000001020308"
},
{
"username": "user2",
"password": "password2",
"privacy_password": "privacy2",
"engineId": "8000000001020308"
},
{
"username": "user3",
"password": "password3",
"privacy_password": "privacy3",
"engineId": "8000000001020305"
}
],
"communities": [
"community1",
"community2"
]
}
Note:
if username is equals to user1 then expected output(then the user subjson should be removed):
{
"users": [
{
"username": "user2",
"password": "password2",
"privacy_password": "privacy2",
"engineId": "8000000001020308"
},
{
"username": "user3",
"password": "password3",
"privacy_password": "privacy3",
"engineId": "8000000001020305"
}
],
"communities": [
"community1",
"community2"
]
}
Note2: same as if it matches username is equals to user2 then user2 subjsons should be removed from the input. username will come dynamic out of three subjsons in the above input, if it matches deleted and print remaining as it.
Assuming a value is presented as an extra attribute
"un" : "user1"added by a default transformation spec for comparison as you've suggested within the comment, then you can consider using the following complete transformation :