Forum Discussion
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.
nickhumble - could you simply enable the "Null-safe access" option and always reference the values you're looking for? If it doesn't exist, it will just be a null value. This would bypass the need for the get() method, which as you have found out, can't be used under multiple levels of object nesting.
- nickhumble2 years agoNew Contributor II
Thanks koryknick - this might just be the simplistic genius i was looking for!
If that doesn't work for you, then try this:
$.get('/position/field_2354910', {}).get('value')
Since the Object.get() method allows you to provide a default if the field doesn't exist, this example returns an empty object, so calling the next get() on the empty object will also return null.
Hope this helps!
- nickhumble2 years agoNew Contributor II
Thanks - my problem was i couldn't get a non-null value using .get, no matter what i tried. I wondered whether the forward slashes were confusing it or something, but .hasPath worked ok so i'm a bit stumped.
Your earlier suggestion has worked well though - thank you.
Related Content
- 2 years ago
- 3 years ago
- 2 years ago