I would like to retrieve the object that contains a specific value in the key name.
So for example, if I wanted sensor2, it would produce a payload output;
The node producing the flow may not include the value (sensor2) at all, or may produce an object with a different format, in which cases I would expect no match, and therefore no output. Also the position of "name": "sensor2" may not be in the same order within the objects.
I've been tying by using Object.entries but failing so far...
If you are just wanting to replace the payload with a single object having that specific name, you can use the JSONata expression payload.*[name="sensor2"] in a change node.
To use another field (e.g. 'topic') as the lookup key, try payload.*[name=$$.topic] -- the $$. prefix in this case is necessary in order to reset the context to look for the topic field in the root of the msg object.