Clearly I made a mistake in referring to it as an array, but I provided precisely what the input data looks like (i.e. now I understand that it's nested objects).
I understand, that's what I suspected, that it's simply a limitation of the debug node.
Still confused, I did provide the example of how I wanted to filter the data (conditional values) - in fact, you provided the jsonata expression to do that ?
[{"id":"29b7a996ff9053cc","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"change","pt":"msg","to":"0","tot":"num"},{"t":"set","p":"price_min","pt":"msg","to":"100","tot":"num"},{"t":"set","p":"price_max","pt":"msg","to":"300","tot":"num"},{"t":"set","p":"payload","pt":"msg","to":"$sift($$.payload.data.data, function($v,$k)\t{$v.change > $$.change and $v.price > $$.price_min and $v.price < $$.price_max}\t)\t\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":7840,"wires":[["4e5340ffce155365"]]},{"id":"4ad42215ec3280f3","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{ \"status\": 200, \"data\": { \"data\": { \"AAPL\": { \"volume\": 18457363, \"price\": 230.42, \"change\": -0.15, \"float\": 15179469955, \"relativeVolume\": 36.30859039199602, \"shortRatio\": 2.32, \"shortFloat\": 0.93377, \"daysGap\": -0.34, \"averageVolume\": 39185859.6, \"rsi\": 52.096 }, \"NVDA\": { \"volume\": 130080525, \"price\": 139.7328, \"change\": 0.12, \"float\": 23541535433, \"relativeVolume\": 40.00929295738587, \"shortRatio\": 0.8, \"shortFloat\": 1.06658, \"daysGap\": 0.9, \"averageVolume\": 254269218.6, \"rsi\": 62.832 } } } }","payloadType":"json","x":190,"y":7840,"wires":[["29b7a996ff9053cc"]]}]
This expression generated an output (of nested objects), which I then need to split, and that resulted in loosing the stock symbol (i.e. ADT) so I experimented in converting it to the output format that I want:
[{"volume":29079654,"price":8.14,"change":17.63,"float":277767777,"relativeVolume":669.3863072501292,"shortRatio":5.15,"shortFloat":8.47932,"daysGap":6.65,"name":"ADT"},{"volume":68074619,"price":6.5,"change":25.48,"float":371136076,"relativeVolume":1183.5067008672897,"shortRatio":11.73,"shortFloat":15.03023,"daysGap":18.34,"name":"QS"},{"volume":14397838,"price":14.3,"change":29.53,"float":89476163,"relativeVolume":597.0198431094809,"shortRatio":12.8,"shortFloat":50.04126,"daysGap":1,"name":"PCT"},{"volume":8587131,"price":13.82,"change":10.91,"float":108788732,"relativeVolume":584.1824156088004,"shortRatio":3.04,"shortFloat":3.32353,"daysGap":18.14,"name":"LC"},{"volume":269585,"price":8.0965,"change":15.5,"float":1385027955,"relativeVolume":1879.6890252405522,"shortRatio":1.43,"shortFloat":0.00205,"daysGap":-1.71,"name":"IONR"},{"volume":216922,"price":10.78,"change":21.81,"float":189571070,"relativeVolume":560.5219638242894,"daysGap":10.17,"name":"NVA"}]
The biggest problem right now is the fact the filtering (jsonata expression) is not producing the expected set of records. Initially I thought they might have been missing in the input data, but as I mentioned I proceeded to copy/paste (directly from debug node) the raw data into excel and confirmed that those records existed. Have no idea what's going on there and how to troubleshoot.
P.S. Just tried sending the converted data to file node, but instead of 5527 records the text file only contained two; I ran it several times, confirming in the debug console that the data going into the file node looked like this (so another mystery):
No you provided an input object and the conditional logic, not the values.
So my OG expression filtered the object. You never provided an example showing you wanted an array with the NVDA etc value added.
You then said you wanted the objects property (NVDA etc) added to the object and return an array. I then pointed out you never gave us a output example in your OG post, which would of eliminated the assumptions we had to make.
I then provide this
Which is an example of of adding the NVDA to the object and returning an array.
Example of how best to provide info that reduces assumptions when we reply.
Input
{
"status": 200,
"data": {
"data": {
"AAPL": {
"volume": 18457363,
"price": 230.42,
"change": -0.15,
"float": 15179469955,
"relativeVolume": 36.30859039199602,
"shortRatio": 2.32,
"shortFloat": 0.93377,
"daysGap": -0.34,
"averageVolume": 39185859.6,
"rsi": 52.096
},
"NVDA": {
"volume": 130080525,
"price": 139.7328,
"change": 0.12,
"float": 23541535433,
"relativeVolume": 40.00929295738587,
"shortRatio": 0.8,
"shortFloat": 1.06658,
"daysGap": 0.9,
"averageVolume": 254269218.6,
"rsi": 62.832
}
}
}
}
conditionals
change > $$.change and price > $$.price_min and price < $$.price_max
Value for output
change > 0
price_min 100
price_max 300
expected output
[
{
"stock": "NVDA",
"volume": 130080525,
"price": 139.7328,
"change": 0.12,
"float": 23541535433,
"relativeVolume": 40.00929295738587,
"shortRatio": 0.8,
"shortFloat": 1.06658,
"daysGap": 0.9,
"averageVolume": 254269218.6,
"rsi": 62.832
}
]
Remember we volunteer our time, so the clearer you make the question the less time we waste.
This has been answered, there is no missing data the debug limits its display, when you copy the value it is all there.
More info is needed as working for me with the input you provided.
[{"id":"4ad42215ec3280f3","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{ \"status\": 200, \"data\": { \"data\": { \"AAPL\": { \"volume\": 18457363, \"price\": 230.42, \"change\": -0.15, \"float\": 15179469955, \"relativeVolume\": 36.30859039199602, \"shortRatio\": 2.32, \"shortFloat\": 0.93377, \"daysGap\": -0.34, \"averageVolume\": 39185859.6, \"rsi\": 52.096 }, \"NVDA\": { \"volume\": 130080525, \"price\": 139.7328, \"change\": 0.12, \"float\": 23541535433, \"relativeVolume\": 40.00929295738587, \"shortRatio\": 0.8, \"shortFloat\": 1.06658, \"daysGap\": 0.9, \"averageVolume\": 254269218.6, \"rsi\": 62.832 } } } }","payloadType":"json","x":210,"y":7700,"wires":[["29b7a996ff9053cc"]]},{"id":"29b7a996ff9053cc","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"change","pt":"msg","to":"0","tot":"num"},{"t":"set","p":"price_min","pt":"msg","to":"100","tot":"num"},{"t":"set","p":"price_max","pt":"msg","to":"300","tot":"num"},{"t":"set","p":"payload","pt":"msg","to":"[$each(\t $$.payload.data.data, \t function($v,$k){\t $v.change > $$.change and $v.price > $$.price_min and $v.price < $$.price_max ?\t $merge([{\"stock\":$k}, $v])\t }\t)]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":7700,"wires":[["4e5340ffce155365"]]},{"id":"4e5340ffce155365","type":"debug","z":"d1395164b4eec73e","name":"debug 2580","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":7700,"wires":[]}]
I understand (doing my best). Your last jsonota expression did exactly what I was looking for. Thanks so much for your time.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.