Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if condition in array values #28

Open
khushboobansal1910 opened this issue Oct 16, 2018 · 1 comment
Open

if condition in array values #28

khushboobansal1910 opened this issue Oct 16, 2018 · 1 comment

Comments

@khushboobansal1910
Copy link

Hi,

I have a doubt. I am trying to do transformation.

Consider that my input data is like below :
var data = {
"balance":{
"amount": 100
},
"disposable":{
"amount":200
}
};

For the above data I want to create template such that it return me an array of balances which consists of objects having two attributes "balancetype" and "amount".
If data has balance then it should return me "balancetype":"interim" and "amount":"balance.amount" and if data has disposable then it should return me "balancetype":"extrim" and "amount":"disposable .amount" .
Note: If data has both balance and disposable then balances array should have two objects and if data has either of balance and disposable then balances array should have one object and if data is not having both of balance and disposable then balances array should not be returned.

Case 1:
var data = {
"name": "khushboo",
"balance":{
"amount": 100
},
"disposable":{
"amount":200
}
};

Expected Output:
{"balances":[
{ "balancetype":"interim",
"amount": 100
},
{ "balancetype":"extrim",
"amount": 200
}
]
}

Case 2:
var data = {
"name": "khushboo",
"balance":{
"amount": 100
}
};

Expected Output:
{"balances":[
{ "balancetype":"interim",
"amount": 100
}
]
}

Case 2:
var data = {
"name": "khushboo"
};

Expected Output:
{
}

Please help me in providing such a template.

@khushboobansal1910
Copy link
Author

@gliechtenstein , @mihir83in Please help it's really urgent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant