10-09-2020 07:16 AM
I have the following document with question responses. When the response is “-”, I would like to remove the question and answer text. Is there a way to do this in a mapper or conditional step?
Before:
[{
“Questions”: [ {
“answerText”: “John”,
“Question_ID”: “FIRST_NAME”
},
{
** “answerText”: “-”,**
** “Question_ID”: “ADDRESS”**
** },**
{
“answerText”: “888-888-8888”,
“Question_ID”: “PHONE”
}
]
}]
After
[{
“Questions”: [ {
“answerText”: “John”,
“Question_ID”: “FIRST_NAME”
},
{
“answerText”: “888-888-8888”,
“Question_ID”: “PHONE”
}
]
}]
Solved! Go to Solution.
10-09-2020 07:41 AM
I used a JSON generator snap with your array of objects at the key Questions
and a mapper to filter the array with this expression in a mapper:
$Questions.filter(value => value.get("answerText") != "-")
This will remove all objects with answerText
== ‘-’.
This relies on the objects having the key answerText
if that is not the case some additional logic can be added if needed.
10-09-2020 07:41 AM
I used a JSON generator snap with your array of objects at the key Questions
and a mapper to filter the array with this expression in a mapper:
$Questions.filter(value => value.get("answerText") != "-")
This will remove all objects with answerText
== ‘-’.
This relies on the objects having the key answerText
if that is not the case some additional logic can be added if needed.