Extract values JSON string from pcap

You would acccess the info in the function node at
msg.payload.payload.payload.rest of path

But probably better to move the object. move msg.payload.payload.payload to msg.payload. or another variable.
so at beginning of function
let data = msg.payload.payload.payload;

then access data.dhost.addr[1];

I've tried

data = msg.payload.payload.payload;
p = data.dhost.addr[1];
return p;

But says

11/6/2020, 10:45:31 PMnode: cf7729c9.d2926function : (error)
"TypeError: Cannot read property 'addr' of undefined"

Use the path copy function to get exact path to variable

Try let data = msg.payload.payload;
or as steve suggests copy the path directly from the debug output in the side panel.

Also return p; will result in Error function tried to return number, You have to return an object, not a string or number.

I've done the "copy the path" from a given variable, below [0...9] is the variable 0: 0xff

The copied path is:


Then, inside the function done I just simply code:

msg = msg.payload.payload.payload.payload.payload.data[0]
return msg;

And I get this error:

"TypeError: Cannot read property 'data' of undefined"

Your path has 4 payloads, but you msg = has 5 payloads. Normally you just add msg. to path.

Like this:

msg = msg.payload.payload.payload.payload.data[0];
return msg;

I get:

11/7/2020, 10:53:14 AMnode: cf7729c9.d2926function : (error) "Function tried to send a message of type number"

I said in a previous comment, you have to return an object
msg.payload = msg.payload.payload.etc;

I though i can use data as a variable. I got this object


How can I get the value 255 from payload?

Where ever you need to input 255, use msg.payload

In case I need to collect multiple values, how can I do to keep those values in different variables? Since using msg.payload will only collect one unique value. I mean, I want to keep all values from 0 to 99 for later insert them into a JSON structure.

@rpanda I think it would be worth your while spending an hour or so working right through the Node-red Essentials video guides that are linked from the node-red docs. That would save you a lot of time in the long run.

msg.any_name_you_wish = msg.payload.etc

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.