I have an issue whereby I need to access a data inside a dynamically generated payload, the position I need to access is always the same, but the name of a certain level is generated as part of the return...
example:
msg.raw.thischanges.price
I thought I could access it via:
var example = msg.raw[0].price but this doesn't work.
What's the best way to achieve this using a function node?
Is there always exactly one property under msg.raw ? And that is the property you care about? Or could there be other properties there, and if so, how do you know which is the one you want?
If there is exactly one, then you could use a Change node using a JSONata expression. Configure the node to set msg.myValue to the expression $.raw.*.price. Pass that result to your Function node where you can use msg.myValue however you want.
If you already know the value of 'thischanges' then you can do msg.payload.RAW[thischanges]
where thischangesis a variable.
I note, however that the the content attribute you show has a space before BTC whereas the attribute name doesn't