Addressing array variables

Hi!

I have incoming array sets that get displayed in a tabulator table, where selected variables from each array (e.g. payload[0].position.units.value) make up the row. Table setup was straightforward, I simply point to (position.units.value). The one thing I couldn't figure out is how to reference values that are in a nested array such as (payload[0].take_profit.steps[0].price.value)

However, also I need to pre-process some of these variables (truncate characters, get absolute values, calculate percentages) and I can't figure out how to reference them (because it's an array). I imagine that jsonata expressions in change node would be the more elegant approach but a function (before the table) would be easier to work with if I could figure out how to reference.

Thanks!

[{"id":21299831,"version":2,"account":{"id":31430770,"type":"paper_trading","name":"Paper Account","market":"Paper trading account","link":"/accounts/31430770"},"pair":"USDT_SOL","instant":false,"status":{"type":"waiting_targets","basic_type":"waiting_targets","title":"Waiting Targets"},"leverage":{"enabled":false},"position":{"type":"buy","editable":false,"units":{"value":"7.14","editable":false},"price":{"value":"14.0","value_without_commission":"13.99","editable":false},"total":{"value":"99.9884886"},"order_type":"market","status":{"type":"finished","basic_type":"finished","title":"Finished"}},"take_profit":{"enabled":true,"steps":[{"id":88999211,"order_type":"market","editable":true,"units":{"value":"7.14"},"price":{"value":"14.7","type":"last","percent":null},"volume":"100.0","total":"104.958","trailing":{"enabled":true,"percent":"-2.0"},"status":{"type":"to_process","basic_type":"to_process","title":"Pending"},"data":{"cancelable":true,"panic_sell_available":true},"position":1}]},"stop_loss":{"enabled":true,"breakeven":false,"order_type":"market","editable":true,"price":{"value":null},"conditional":{"price":{"value":"13.58","type":"last","percent":null},"trailing":{"enabled":true,"percent":null}},"timeout":{"enabled":true,"value":2},"status":{"type":"trailing_activated","basic_type":"trailing_activated","title":"Trailing Activated"}},"reduce_funds":{"steps":[]},"market_close":{},"note":"","note_raw":null,"skip_enter_step":false,"data":{"editable":true,"current_price":{"day_change_percent":"-3.65","bid":"13.98","ask":"13.99","last":"13.99","quote_volume":"65476182.3279"},"target_price_type":"price","base_order_finished":true,"missing_funds_to_close":0,"liquidation_price":null,"average_enter_price":"14.0","average_close_price":null,"average_enter_price_without_commission":"13.99","average_close_price_without_commission":null,"panic_sell_available":true,"add_funds_available":true,"reduce_funds_available":true,"force_start_available":false,"force_process_available":true,"cancel_available":true,"finished":false,"base_position_step_finished":true,"entered_amount":"7.14","entered_total":"99.9884886","closed_amount":"0.0","closed_total":"0.0","created_at":"2022-11-16T17:25:43.419Z","updated_at":"2022-11-16T17:25:43.419Z","type":"smart_trade"},"profit":{"volume":"-0.2711058","usd":"-0.2711058","percent":"-0.27","roe":null},"margin":{"amount":null,"total":null},"is_position_not_filled":false},{"id":21299047,"version":2,"account":{"id":31430770,"type":"paper_trading","name":"Paper Account","market":"Paper trading account","link":"/accounts/31430770"},"pair":"USDT_UNI","instant":false,"status":{"type":"waiting_targets","basic_type":"waiting_targets","title":"Waiting Targets"},"leverage":{"enabled":false},"position":{"type":"buy","editable":false,"units":{"value":"16.88","editable":false},"price":{"value":"5.94","value_without_commission":"5.94","editable":false},"total":{"value":"100.3674672"},"order_type":"market","status":{"type":"finished","basic_type":"finished","title":"Finished"}},"take_profit":{"enabled":true,"steps":[{"id":88989211,"order_type":"market","editable":true,"units":{"value":"16.88"},"price":{"value":"6.22","type":"last","percent":null},"volume":"100.0","total":"104.9936","trailing":{"enabled":true,"percent":"-2.0"},"status":{"type":"to_process","basic_type":"to_process","title":"Pending"},"data":{"cancelable":true,"panic_sell_available":true},"position":1}]},"stop_loss":{"enabled":true,"breakeven":false,"order_type":"market","editable":true,"price":{"value":null},"conditional":{"price":{"value":"5.76","type":"last","percent":null},"trailing":{"enabled":true,"percent":null}},"timeout":{"enabled":true,"value":2},"status":{"type":"trailing_activated","basic_type":"trailing_activated","title":"Trailing Activated"}},"reduce_funds":{"steps":[]},"market_close":{},"note":"","note_raw":null,"skip_enter_step":false,"data":{"editable":true,"current_price":{"day_change_percent":"-7.332","bid":"5.93","ask":"5.94","last":"5.94","quote_volume":"15732336.49"},"target_price_type":"price","base_order_finished":true,"missing_funds_to_close":"16.88","liquidation_price":null,"average_enter_price":"5.94","average_close_price":null,"average_enter_price_without_commission":"5.94","average_close_price_without_commission":null,"panic_sell_available":true,"add_funds_available":true,"reduce_funds_available":true,"force_start_available":false,"force_process_available":true,"cancel_available":true,"finished":false,"base_position_step_finished":true,"entered_amount":"16.88","entered_total":"100.3674672","closed_amount":"0.0","closed_total":"0.0","created_at":"2022-11-16T16:40:59.197Z","updated_at":"2022-11-16T16:40:59.197Z","type":"smart_trade"},"profit":{"volume":"-0.3691656","usd":"-0.3691656","percent":"-0.37","roe":null},"margin":{"amount":null,"total":null},"is_position_not_filled":false},{"id":21298671,"version":2,"account":{"id":31430770,"type":"paper_trading","name":"Paper Account","market":"Paper trading account","link":"/accounts/31430770"},"pair":"USDT_ETH","instant":false,"status":{"type":"waiting_targets","basic_type":"waiting_targets","title":"Waiting Targets"},"leverage":{"enabled":false},"position":{"type":"buy","editable":false,"units":{"value":"0.08","editable":false},"price":{"value":"1197.99","value_without_commission":"1196.8","editable":false},"total":{"value":"95.839744"},"order_type":"market","status":{"type":"finished","basic_type":"finished","title":"Finished"}},"take_profit":{"enabled":true,"steps":[{"id":88984495,"order_type":"market","editable":true,"units":{"value":"0.08"},"price":{"value":"1260.44","type":"last","percent":null},"volume":"100.0","total":"100.8352","trailing":{"enabled":true,"percent":"-2.0"},"status":{"type":"to_process","basic_type":"to_process","title":"Pending"},"data":{"cancelable":true,"panic_sell_available":true},"position":1}]},"stop_loss":{"enabled":true,"breakeven":false,"order_type":"market","editable":true,"price":{"value":null},"conditional":{"price":{"value":"1178.71","type":"last","percent":null},"trailing":{"enabled":true,"percent":null}},"timeout":{"enabled":true,"value":2},"status":{"type":"trailing_activated","basic_type":"trailing_activated","title":"Trailing Activated"}},"reduce_funds":{"steps":[]},"market_close":{},"note":"","note_raw":null,"skip_enter_step":false,"data":{"editable":true,"current_price":{"day_change_percent":"-4.723","bid":"1209.13","ask":"1209.14","last":"1209.14","quote_volume":"896511658.546651"},"target_price_type":"price","base_order_finished":true,"missing_funds_to_close":"0.0","liquidation_price":null,"average_enter_price":"1197.99","average_close_price":null,"average_enter_price_without_commission":"1196.8","average_close_price_without_commission":null,"panic_sell_available":true,"add_funds_available":true,"reduce_funds_available":true,"force_start_available":false,"force_process_available":true,"cancel_available":true,"finished":false,"base_position_step_finished":true,"entered_amount":"0.08","entered_total":"95.839744","closed_amount":"0.0","closed_total":"0.0","created_at":"2022-11-16T16:21:33.776Z","updated_at":"2022-11-16T16:21:33.776Z","type":"smart_trade"},"profit":{"volume":"0.7939256","usd":"0.7939256","percent":"0.83","roe":null},"margin":{"amount":null,"total":null},"is_position_not_filled":false},{"id":21298596,"version":2,"account":{"id":31430770,"type":"paper_trading","name":"Paper Account","market":"Paper trading account","link":"/accounts/31430770"},"pair":"USDT_SOL","instant":false,"status":{"type":"waiting_targets","basic_type":"waiting_targets","title":"Waiting Targets"},"leverage":{"enabled":false},"position":{"type":"buy","editable":false,"units":{"value":"7.2","editable":false},"price":{"value":"13.92","value_without_commission":"13.91","editable":false},"total":{"value":"100.252152"},"order_type":"market","status":{"type":"finished","basic_type":"finished","title":"Finished"}},"take_profit":{"enabled":true,"steps":[{"id":88983383,"order_type":"market","editable":true,"units":{"value":"7.2"},"price":{"value":"14.58","type":"last","percent":null},"volume":"100.0","total":"104.976","trailing":{"enabled":true,"percent":"-2.0"},"status":{"type":"to_process","basic_type":"to_process","title":"Pending"},"data":{"cancelable":true,"panic_sell_available":true},"position":1}]},"stop_loss":{"enabled":true,"breakeven":false,"order_type":"market","editable":true,"price":{"value":null},"conditional":{"price":{"value":"13.56","type":"last","percent":null},"trailing":{"enabled":true,"percent":null}},"timeout":{"enabled":true,"value":2},"status":{"type":"trailing_activated","basic_type":"trailing_activated","title":"Trailing Activated"}},"reduce_funds":{"steps":[]},"market_close":{},"note":"","note_raw":null,"skip_enter_step":false,"data":{"editable":true,"current_price":{"day_change_percent":"-3.65","bid":"13.98","ask":"13.99","last":"13.99","quote_volume":"65476182.3279"},"target_price_type":"price","base_order_finished":true,"missing_funds_to_close":0,"liquidation_price":null,"average_enter_price":"13.92","average_close_price":null,"average_enter_price_without_commission":"13.91","average_close_price_without_commission":null,"panic_sell_available":true,"add_funds_available":true,"reduce_funds_available":true,"force_start_available":false,"force_process_available":true,"cancel_available":true,"finished":false,"base_position_step_finished":true,"entered_amount":"7.2","entered_total":"100.252152","closed_amount":"0.0","closed_total":"0.0","created_at":"2022-11-16T16:16:49.795Z","updated_at":"2022-11-16T16:16:49.795Z","type":"smart_trade"},"profit":{"volume":"0.303192","usd":"0.303192","percent":"0.3","roe":null},"margin":{"amount":null,"total":null},"is_position_not_filled":false}]

As you are showing the data in the debug panel, you should realise that you can copy the "path" of the property you want.

image

I gave path example as well: payload[0].take_profit.steps[0].price.value

Add at that start of the function

node.warn(`value: ${msg.payload[0].take_profit.steps[0].price.value}`)

and see what appears in the debug pane

Edit: corrected the code above.

I get the value ("value: 14.85"), I know, but that's just referencing the msg.payload[0] record - my confusion is what to specify in tabulator table config so it cycles through records. In case of other variables, say "payload[0].position.units.value", I could simply reference "position.units.value" - same approach doesn't work here, "take_profit.steps[0].price.value" does not work. Note that in the subarray it is always going to be a single "[0]" record.

Why not move the contents of the steps[0] to steps property. Then you can reference it as you would the other values.
e.g.

[{"id":"47918bd2289f985c","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"id\":21299831,\"version\":2,\"account\":{\"id\":31430770,\"type\":\"paper_trading\",\"name\":\"Paper Account\",\"market\":\"Paper trading account\",\"link\":\"/accounts/31430770\"},\"pair\":\"USDT_SOL\",\"instant\":false,\"status\":{\"type\":\"waiting_targets\",\"basic_type\":\"waiting_targets\",\"title\":\"Waiting Targets\"},\"leverage\":{\"enabled\":false},\"position\":{\"type\":\"buy\",\"editable\":false,\"units\":{\"value\":\"7.14\",\"editable\":false},\"price\":{\"value\":\"14.0\",\"value_without_commission\":\"13.99\",\"editable\":false},\"total\":{\"value\":\"99.9884886\"},\"order_type\":\"market\",\"status\":{\"type\":\"finished\",\"basic_type\":\"finished\",\"title\":\"Finished\"}},\"take_profit\":{\"enabled\":true,\"steps\":[{\"id\":88999211,\"order_type\":\"market\",\"editable\":true,\"units\":{\"value\":\"7.14\"},\"price\":{\"value\":\"14.7\",\"type\":\"last\",\"percent\":null},\"volume\":\"100.0\",\"total\":\"104.958\",\"trailing\":{\"enabled\":true,\"percent\":\"-2.0\"},\"status\":{\"type\":\"to_process\",\"basic_type\":\"to_process\",\"title\":\"Pending\"},\"data\":{\"cancelable\":true,\"panic_sell_available\":true},\"position\":1}]},\"stop_loss\":{\"enabled\":true,\"breakeven\":false,\"order_type\":\"market\",\"editable\":true,\"price\":{\"value\":null},\"conditional\":{\"price\":{\"value\":\"13.58\",\"type\":\"last\",\"percent\":null},\"trailing\":{\"enabled\":true,\"percent\":null}},\"timeout\":{\"enabled\":true,\"value\":2},\"status\":{\"type\":\"trailing_activated\",\"basic_type\":\"trailing_activated\",\"title\":\"Trailing Activated\"}},\"reduce_funds\":{\"steps\":[]},\"market_close\":{},\"note\":\"\",\"note_raw\":null,\"skip_enter_step\":false,\"data\":{\"editable\":true,\"current_price\":{\"day_change_percent\":\"-3.65\",\"bid\":\"13.98\",\"ask\":\"13.99\",\"last\":\"13.99\",\"quote_volume\":\"65476182.3279\"},\"target_price_type\":\"price\",\"base_order_finished\":true,\"missing_funds_to_close\":0,\"liquidation_price\":null,\"average_enter_price\":\"14.0\",\"average_close_price\":null,\"average_enter_price_without_commission\":\"13.99\",\"average_close_price_without_commission\":null,\"panic_sell_available\":true,\"add_funds_available\":true,\"reduce_funds_available\":true,\"force_start_available\":false,\"force_process_available\":true,\"cancel_available\":true,\"finished\":false,\"base_position_step_finished\":true,\"entered_amount\":\"7.14\",\"entered_total\":\"99.9884886\",\"closed_amount\":\"0.0\",\"closed_total\":\"0.0\",\"created_at\":\"2022-11-16T17:25:43.419Z\",\"updated_at\":\"2022-11-16T17:25:43.419Z\",\"type\":\"smart_trade\"},\"profit\":{\"volume\":\"-0.2711058\",\"usd\":\"-0.2711058\",\"percent\":\"-0.27\",\"roe\":null},\"margin\":{\"amount\":null,\"total\":null},\"is_position_not_filled\":false},{\"id\":21299047,\"version\":2,\"account\":{\"id\":31430770,\"type\":\"paper_trading\",\"name\":\"Paper Account\",\"market\":\"Paper trading account\",\"link\":\"/accounts/31430770\"},\"pair\":\"USDT_UNI\",\"instant\":false,\"status\":{\"type\":\"waiting_targets\",\"basic_type\":\"waiting_targets\",\"title\":\"Waiting Targets\"},\"leverage\":{\"enabled\":false},\"position\":{\"type\":\"buy\",\"editable\":false,\"units\":{\"value\":\"16.88\",\"editable\":false},\"price\":{\"value\":\"5.94\",\"value_without_commission\":\"5.94\",\"editable\":false},\"total\":{\"value\":\"100.3674672\"},\"order_type\":\"market\",\"status\":{\"type\":\"finished\",\"basic_type\":\"finished\",\"title\":\"Finished\"}},\"take_profit\":{\"enabled\":true,\"steps\":[{\"id\":88989211,\"order_type\":\"market\",\"editable\":true,\"units\":{\"value\":\"16.88\"},\"price\":{\"value\":\"6.22\",\"type\":\"last\",\"percent\":null},\"volume\":\"100.0\",\"total\":\"104.9936\",\"trailing\":{\"enabled\":true,\"percent\":\"-2.0\"},\"status\":{\"type\":\"to_process\",\"basic_type\":\"to_process\",\"title\":\"Pending\"},\"data\":{\"cancelable\":true,\"panic_sell_available\":true},\"position\":1}]},\"stop_loss\":{\"enabled\":true,\"breakeven\":false,\"order_type\":\"market\",\"editable\":true,\"price\":{\"value\":null},\"conditional\":{\"price\":{\"value\":\"5.76\",\"type\":\"last\",\"percent\":null},\"trailing\":{\"enabled\":true,\"percent\":null}},\"timeout\":{\"enabled\":true,\"value\":2},\"status\":{\"type\":\"trailing_activated\",\"basic_type\":\"trailing_activated\",\"title\":\"Trailing Activated\"}},\"reduce_funds\":{\"steps\":[]},\"market_close\":{},\"note\":\"\",\"note_raw\":null,\"skip_enter_step\":false,\"data\":{\"editable\":true,\"current_price\":{\"day_change_percent\":\"-7.332\",\"bid\":\"5.93\",\"ask\":\"5.94\",\"last\":\"5.94\",\"quote_volume\":\"15732336.49\"},\"target_price_type\":\"price\",\"base_order_finished\":true,\"missing_funds_to_close\":\"16.88\",\"liquidation_price\":null,\"average_enter_price\":\"5.94\",\"average_close_price\":null,\"average_enter_price_without_commission\":\"5.94\",\"average_close_price_without_commission\":null,\"panic_sell_available\":true,\"add_funds_available\":true,\"reduce_funds_available\":true,\"force_start_available\":false,\"force_process_available\":true,\"cancel_available\":true,\"finished\":false,\"base_position_step_finished\":true,\"entered_amount\":\"16.88\",\"entered_total\":\"100.3674672\",\"closed_amount\":\"0.0\",\"closed_total\":\"0.0\",\"created_at\":\"2022-11-16T16:40:59.197Z\",\"updated_at\":\"2022-11-16T16:40:59.197Z\",\"type\":\"smart_trade\"},\"profit\":{\"volume\":\"-0.3691656\",\"usd\":\"-0.3691656\",\"percent\":\"-0.37\",\"roe\":null},\"margin\":{\"amount\":null,\"total\":null},\"is_position_not_filled\":false},{\"id\":21298671,\"version\":2,\"account\":{\"id\":31430770,\"type\":\"paper_trading\",\"name\":\"Paper Account\",\"market\":\"Paper trading account\",\"link\":\"/accounts/31430770\"},\"pair\":\"USDT_ETH\",\"instant\":false,\"status\":{\"type\":\"waiting_targets\",\"basic_type\":\"waiting_targets\",\"title\":\"Waiting Targets\"},\"leverage\":{\"enabled\":false},\"position\":{\"type\":\"buy\",\"editable\":false,\"units\":{\"value\":\"0.08\",\"editable\":false},\"price\":{\"value\":\"1197.99\",\"value_without_commission\":\"1196.8\",\"editable\":false},\"total\":{\"value\":\"95.839744\"},\"order_type\":\"market\",\"status\":{\"type\":\"finished\",\"basic_type\":\"finished\",\"title\":\"Finished\"}},\"take_profit\":{\"enabled\":true,\"steps\":[{\"id\":88984495,\"order_type\":\"market\",\"editable\":true,\"units\":{\"value\":\"0.08\"},\"price\":{\"value\":\"1260.44\",\"type\":\"last\",\"percent\":null},\"volume\":\"100.0\",\"total\":\"100.8352\",\"trailing\":{\"enabled\":true,\"percent\":\"-2.0\"},\"status\":{\"type\":\"to_process\",\"basic_type\":\"to_process\",\"title\":\"Pending\"},\"data\":{\"cancelable\":true,\"panic_sell_available\":true},\"position\":1}]},\"stop_loss\":{\"enabled\":true,\"breakeven\":false,\"order_type\":\"market\",\"editable\":true,\"price\":{\"value\":null},\"conditional\":{\"price\":{\"value\":\"1178.71\",\"type\":\"last\",\"percent\":null},\"trailing\":{\"enabled\":true,\"percent\":null}},\"timeout\":{\"enabled\":true,\"value\":2},\"status\":{\"type\":\"trailing_activated\",\"basic_type\":\"trailing_activated\",\"title\":\"Trailing Activated\"}},\"reduce_funds\":{\"steps\":[]},\"market_close\":{},\"note\":\"\",\"note_raw\":null,\"skip_enter_step\":false,\"data\":{\"editable\":true,\"current_price\":{\"day_change_percent\":\"-4.723\",\"bid\":\"1209.13\",\"ask\":\"1209.14\",\"last\":\"1209.14\",\"quote_volume\":\"896511658.546651\"},\"target_price_type\":\"price\",\"base_order_finished\":true,\"missing_funds_to_close\":\"0.0\",\"liquidation_price\":null,\"average_enter_price\":\"1197.99\",\"average_close_price\":null,\"average_enter_price_without_commission\":\"1196.8\",\"average_close_price_without_commission\":null,\"panic_sell_available\":true,\"add_funds_available\":true,\"reduce_funds_available\":true,\"force_start_available\":false,\"force_process_available\":true,\"cancel_available\":true,\"finished\":false,\"base_position_step_finished\":true,\"entered_amount\":\"0.08\",\"entered_total\":\"95.839744\",\"closed_amount\":\"0.0\",\"closed_total\":\"0.0\",\"created_at\":\"2022-11-16T16:21:33.776Z\",\"updated_at\":\"2022-11-16T16:21:33.776Z\",\"type\":\"smart_trade\"},\"profit\":{\"volume\":\"0.7939256\",\"usd\":\"0.7939256\",\"percent\":\"0.83\",\"roe\":null},\"margin\":{\"amount\":null,\"total\":null},\"is_position_not_filled\":false},{\"id\":21298596,\"version\":2,\"account\":{\"id\":31430770,\"type\":\"paper_trading\",\"name\":\"Paper Account\",\"market\":\"Paper trading account\",\"link\":\"/accounts/31430770\"},\"pair\":\"USDT_SOL\",\"instant\":false,\"status\":{\"type\":\"waiting_targets\",\"basic_type\":\"waiting_targets\",\"title\":\"Waiting Targets\"},\"leverage\":{\"enabled\":false},\"position\":{\"type\":\"buy\",\"editable\":false,\"units\":{\"value\":\"7.2\",\"editable\":false},\"price\":{\"value\":\"13.92\",\"value_without_commission\":\"13.91\",\"editable\":false},\"total\":{\"value\":\"100.252152\"},\"order_type\":\"market\",\"status\":{\"type\":\"finished\",\"basic_type\":\"finished\",\"title\":\"Finished\"}},\"take_profit\":{\"enabled\":true,\"steps\":[{\"id\":88983383,\"order_type\":\"market\",\"editable\":true,\"units\":{\"value\":\"7.2\"},\"price\":{\"value\":\"14.58\",\"type\":\"last\",\"percent\":null},\"volume\":\"100.0\",\"total\":\"104.976\",\"trailing\":{\"enabled\":true,\"percent\":\"-2.0\"},\"status\":{\"type\":\"to_process\",\"basic_type\":\"to_process\",\"title\":\"Pending\"},\"data\":{\"cancelable\":true,\"panic_sell_available\":true},\"position\":1}]},\"stop_loss\":{\"enabled\":true,\"breakeven\":false,\"order_type\":\"market\",\"editable\":true,\"price\":{\"value\":null},\"conditional\":{\"price\":{\"value\":\"13.56\",\"type\":\"last\",\"percent\":null},\"trailing\":{\"enabled\":true,\"percent\":null}},\"timeout\":{\"enabled\":true,\"value\":2},\"status\":{\"type\":\"trailing_activated\",\"basic_type\":\"trailing_activated\",\"title\":\"Trailing Activated\"}},\"reduce_funds\":{\"steps\":[]},\"market_close\":{},\"note\":\"\",\"note_raw\":null,\"skip_enter_step\":false,\"data\":{\"editable\":true,\"current_price\":{\"day_change_percent\":\"-3.65\",\"bid\":\"13.98\",\"ask\":\"13.99\",\"last\":\"13.99\",\"quote_volume\":\"65476182.3279\"},\"target_price_type\":\"price\",\"base_order_finished\":true,\"missing_funds_to_close\":0,\"liquidation_price\":null,\"average_enter_price\":\"13.92\",\"average_close_price\":null,\"average_enter_price_without_commission\":\"13.91\",\"average_close_price_without_commission\":null,\"panic_sell_available\":true,\"add_funds_available\":true,\"reduce_funds_available\":true,\"force_start_available\":false,\"force_process_available\":true,\"cancel_available\":true,\"finished\":false,\"base_position_step_finished\":true,\"entered_amount\":\"7.2\",\"entered_total\":\"100.252152\",\"closed_amount\":\"0.0\",\"closed_total\":\"0.0\",\"created_at\":\"2022-11-16T16:16:49.795Z\",\"updated_at\":\"2022-11-16T16:16:49.795Z\",\"type\":\"smart_trade\"},\"profit\":{\"volume\":\"0.303192\",\"usd\":\"0.303192\",\"percent\":\"0.3\",\"roe\":null},\"margin\":{\"amount\":null,\"total\":null},\"is_position_not_filled\":false}]","payloadType":"json","x":170,"y":3800,"wires":[["3a1e3b0b70f733a8","35b04db2becc4b19"]]},{"id":"3a1e3b0b70f733a8","type":"change","z":"452103ea51141731","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.payload ~> |$.take_profit|{\"steps\":$.steps[0]}|","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":3760,"wires":[["56bf43241f9cde0b"]]},{"id":"35b04db2becc4b19","type":"function","z":"452103ea51141731","name":"function 18","func":"msg.payload.forEach(obj => {\n    obj.take_profit.steps = obj.take_profit.steps[0]\n})\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":3840,"wires":[["56bf43241f9cde0b"]]},{"id":"56bf43241f9cde0b","type":"debug","z":"452103ea51141731","name":"debug 109","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":3800,"wires":[]}]

[edit ammended for payload array]

Great, thank you!

You can use the split node to access each message in turn

There is no need to do that with all the other variables - why this one?

Because you want to affect a nested property on each array element.

Just give it a go....

Data -> split -> change node (move the contents of the steps[0] to steps property) -> join -> table

The solution that E1cid offered is a much simpler way to do this.

You can take or leave any suggestion provided by any user. Not sure why you felt it necessary to state that.

Let me clarify for anyone following along.You initially said...

I just realized that this is only moving msg.payload[0] - what about msg.payload[1], etc ?

So my suggestion was to use the split node.

It then appears since I wrote that comment @E1cid updated his solution to handle arrays and you have deleted your post.


What I was offering was an idea in the low code sense that was intended to nudge you in the low code direction so you might explore and learn and understand what low code is about.

What @E1cid handed you is a single function solution. And it is a very good solution and you should use it. But did you really learn anything about low code from it?

1 Like

Adding to Steve's info, You would be better off deciding what info you wish to display. Then you can move all that info into an object for each element of the array and give them the property names you wish, you can do it with low code or a Javascript or JSONata solution. This would simplify your table creation and maintenance.

1 Like

The solution that you provided was very straight forward and allowed me to do all of the variable manipulation that I needed - thank you again. Here is an example of how I used it:

   if (obj.take_profit.steps.price.value > 0)  { 
   obj.margin.total = (((obj.take_profit.steps.price.value / obj.data.current_price.last)-1)*100).toFixed(2);     
       
  }

   let x = String(obj.pair)
    obj.pair = x.replace("USDT_", "")

Hello Again! Not sure if you recall, last year you helped me figure how to deal with this type of data array - I have a different challenge now, wondering if you could assist again? Thank you.

{"symbol":"TPT/USDT","high":0.0093782,"low":0.0069001,"bid":0.008059,"ask":0.0080912,"vwap":0.007671787591489715,"close":0.0080734,"last":0.0080734,"percentage":10.95,"baseVolume":11113331.365821,"quoteVolume":85259.117672419,"info":{"currency_pair":"TPT_USDT","last":"0.0080734","lowest_ask":"0.0080912","highest_bid":"0.008059","change_percentage":"10.95","change_utc0":"0.73","change_utc8":"4.83","base_volume":"11113331.365821","quote_volume":"85259.117672419","high_24h":"0.0093782","low_24h":"0.0069001"}}

Please don't tag individuals on the forum, it isn't fair on them. If you have a new problem, please start a new thread so that others can try to help as well. Thanks.

1 Like

I did post it as a new topic but haven't been able to get any solutions; thought I would ask directly from someone who helped with this data before.

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