Forum Discussion

acesario's avatar
acesario
Contributor II
5 years ago
Solved

Remove json object conditionally

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? B...
  • cjhoward18's avatar
    5 years ago

    @acesario

    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.