I am having trouble splitting an array and converting result to a number as follows.
the main array consists of 185 elements
I can split the main array into the element I want with the following ...
var parts = msg.payload.split(",");
msg.payload = parts[65];
return msg;
result " 'outerLeftRearTirePressure': {'value': '227'"
What I need is a msg.payload containing the 227 element as a number but I am having big difficulty, help would be appreciated.
Here's an snippit hope it helps, I tried splice and stuff but what ever I do I end up with "'227'" I cannot seem to get ride of the " " from " ' 277 ' "
That is nearly JSON. If it were then you could feed it into a JSON node and your troubles would be over. Unfortunately it has single quotes in the string instead of double. Where is that coming from? Ideally the source should be fixed to make it valid. Otherwise you could convert all single quotes to double.
Its a python sketch which connects my car and gets data, according to the sketch the result is supposed to be in Jason format, I'm using the exec node to get the result into node-red.
Well it isn't JSON as JSON must use double quotes. Preferably change the sketch accordingly. If you can't do that then you can feed it through a Change node configured with
Feed that into a debug node to check it looks right, then through a JSON node and into a debug node to see what you get. If you don't know what to do with the javascript object then there is a great page in the docs that will explain how to use the debug panel to find the right path to any data item.
Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.