How to extract exact data from payload

Dear all,
I am getting GPS coordinated as a string. Please take a look at bellow screen.
How can I get each value separately. Can I "call" latitude and longitude desperately?
I tried with "payload.payload.value[0]", but it is giving me back only first character. If nothing else, can I call the first 17 characters?
image

Use a split node to split msg.payload.payload.value "split using ," and a join node set to Manual and to create an array.

This will a produce message with latitude as msg.payload[0] and longitude as msg.payload[1]

Note, latitude and longitude remain as strings, not numbers.

Untitled 1

2 Likes

You can also pass it through a csv node, where you can name the lat an lon property and parse the numeric values too.

[{"id":"989e880ce2cf99af","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload.payload.value","v":"1.2,20.4,0.0}","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":110,"y":4720,"wires":[["24733675e0bd9f66"]]},{"id":"24733675e0bd9f66","type":"change","z":"452103ea51141731","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":4720,"wires":[["26de37f379ce117a"]]},{"id":"26de37f379ce117a","type":"csv","z":"452103ea51141731","name":"","sep":",","hdrin":"","hdrout":"none","multi":"one","ret":"\\n","temp":"lat,lon","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":450,"y":4720,"wires":[["79a6e7d13e9387bf"]]},{"id":"79a6e7d13e9387bf","type":"debug","z":"452103ea51141731","name":"debug 234","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":4720,"wires":[]}]

3 Likes

E1cid thank you very much. It is doing exactly what I was looking for.
Regards,Rok

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