Using MQTT Engine, im receiving an array of string, which I want to display only one of the string from the array. Im trying to index the array by using "[2]", but it displays all the strings in the array anyway. How can i display only ie. number 2?
You've created a Script Transform. Justin's given you an Expression Transform.
Remove the [1] from your tag path.
Delete the script transform.
Create an expression transform.
Paste his code straight in and that's it.
Think of expressions as being like Excel functions. It's not a program script but rather one or more functions or operations on variables and it just returns one result (or result set).
Sorry, I'm having a bad day. list() is a script function, not an expression function. Your first attempt was right but Justin, I think, missed the { } braces. Try modifying the script to, list({value})[1]
{value} is what's passed into the transform from the previous operation.
Thats strange... Any chance that this has something to do with MQTT to do? Im publishing data from Nodered/MQTT. The data from nodered looks like this (array):
Then, it is sent via MQTT node. Not sure what is done with the data inside this node. Maybe its sent as 1 complete string, instead of array?
Glad it worked for you.
I just realized I should have left off the return (I was mixing up expressions with scripting there for a bit). I'll edit it so no one else gets confused by it either.
Usually there's a 3rd column that shows what your datatype is that I'm not seeing in your screenshot.