Hi there,
I'm somehow new to Node-RED and I like it very much as I've managed to do some mini personal projects with it.
Right now, I'm stuck with a payload that needs to get filtered out - it looks very similar to the following example as the real one contains hundreds or even thousands of items:
-
This is how the payload looks like in the debug window:
-
This is the payload copy:
{"file_name":"value","filename":"value","name":"value","test":"value","name_file":"value"}
I wish to filter the results of the payload to get only the ones that are ending in 'name'.
I've been trying to search for an answer and the only one that was somehow useful was this one:
https://discourse.nodered.org/t/function-node-to-filter-2-values-out/13296/13?u=relic
More specifically, this line of code (the first one gives me 'undefined' in a change node):
payload ~> | $ | {}, $keys($)~>$filter(/.*_qc/) |
The problem with the above code is that I don't understand it in order to modify it to my liking (I don't know what these signs mean or what they are doing ~>
, | $ |
, ($)
and the last |
from the end).
If I edit it from /.*_qc/
to /name/
or to /.*name/
or to /name.*/
, it doesn't really do much - it filters the results, but now how I want to.
This is the payload:
{"file_name":"value","filename":"value","name":"value","test":"value","name_file":"value"}
This is the filtered payload (with the above code):
{"name":"value","test":"value","name_file":"value"}
This is what I'm trying to achieve:
{"file_name":"value","filename":"value"}
Hopefully I wrote everything in detail in order to get some help, examples or guidance to achieve this!