thank you for providing the data.
Here are 3 ways you can worth with it. The V1 is what I said to do on my very first post.
Demo flow
demo.json (58.2 KB)
thank you for providing the data.
Here are 3 ways you can worth with it. The V1 is what I said to do on my very first post.
Demo flow
demo.json (58.2 KB)
Thanks I appreciate the flow, but I think there's some miscommunication in what I'm looking for help on.
I'm trying to figure out how to extract the JSON object data to begin with. The demo all has the sample data pre cut and pasted and that's not what I'm looking to do.
My programming knowledge is when I was a kid I (vaguely) learned BASIC (yeah, '70s BASIC) so in my head, I could see it as a for/next loop, like (and seriously, I can remember basically zero coding so this will NOT be proper code at all but will hopefully give you the gist of what I'm hoping to achieve):
for x=1-7
let msg.payload.timelines.minutely[x].values.temperature = math.round(msg.payload.temp.x)
next x
And then have that output as 7 separate messages.
Does that clarify what I'm trying to achieve?
Honestly, I kinda knew that would be the case.
And lets not forget, V2 in my demo does what you asked:
but lets not dwell - i am hopeful you now realise why the questions were important to avoid confusion. Lets get your issue resolved...
I'm trying to figure out how to extract the JSON object data to begin with.
That is not clear Im afraid. What exactly is it you want to output?
can you provide a sample of what the final output will look like.
e.g.
msg.payload.timelines.minutely
to msg.payload
so that you can access ALL of the OBJECT via msg.payoad[x]
?Hopefully since we have given you a couple of demos (that as predicted were not what you wanted) - perhaps you can help us to help you?
I 'd msg.payload.timelines.minutely[x].values.temperature
- which is a number - to become x separate payloads. So if:
msg.payload.timelines.minutely[1].values.temperature
is number 52
msg.payload.timelines.minutely[2].values.temperature
is number 58
msg.payload.timelines.minutely[3].values.temperature
is number 55
etc. etc. through all the values in the array
then I want, as output, x messages:
msg.payload.1
= 52
msg.payload.2
= 58
msg.payload.3
= 55
Is that clearer?
msg.payload.1
= 52
msg.payload.2
= 58
msg.payload.3
= 55Is that clearer?
Perfect (though I would strongly not recommend that since using numbers as property names is not good practice)
and, in essence, V1 of the demo pretty much does that but with array syntax e.g. msg.payload[1]
is the temperature of msg.payload.timelines.minutely[1].values.temperature
, msg.payload.timelines.minutely[2].values.temperature
is in msg.payload[2]
is that not good enough?
If you give me 5 mins, I can provide the non-recommended output you asked for!
I want, as output, x messages:
msg.payload.1
= 52
msg.payload.2
= 58
msg.payload.3
= 55
You really want an element "1" in your first message with the value 52, an element "2" in your second message with value 58, etc?
Or do you want your message1 to contain just 52, message2 to contain 58 etc?
How will you be using these values further along the flow?
I want, as output, x messages:
msg.payload.1
= 52
msg.payload.2
= 58
msg.payload.3
= 55
Here you go...
[{"id":"d66888a262efc6d6","type":"comment","z":"2290795c114cdec3","name":"V4: same as V1 but converts the array to an object with numbered properties","info":"","x":540,"y":660,"wires":[]},{"id":"fa6d0402d2f3ede5","type":"inject","z":"2290795c114cdec3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":320,"y":700,"wires":[["22793515a532fd28"]]},{"id":"22793515a532fd28","type":"template","z":"2290795c114cdec3","name":"sample data","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n \"timelines\": {\n \"minutely\": [\n {\n \"time\": \"2024-11-02T12:15:00Z\",\n \"values\": {\n \"cloudBase\": null,\n \"cloudCeiling\": null,\n \"cloudCover\": 0,\n \"dewPoint\": 35.26,\n \"freezingRainIntensity\": 0,\n \"humidity\": 58,\n \"precipitationProbability\": 0,\n \"pressureSurfaceLevel\": 30.21,\n \"rainIntensity\": 0,\n \"sleetIntensity\": 0,\n \"snowIntensity\": 0,\n \"temperature\": 49.66,\n \"temperatureApparent\": 49.66,\n \"uvHealthConcern\": 0,\n \"uvIndex\": 0,\n \"visibility\": 9.94,\n \"weatherCode\": 1000,\n \"windDirection\": 333.88,\n \"windGust\": 19.85,\n \"windSpeed\": 6.99\n }\n },\n {\n \"time\": \"2024-11-02T12:16:00Z\",\n \"values\": {\n \"cloudBase\": null,\n \"cloudCeiling\": null,\n \"cloudCover\": 0.04,\n \"dewPoint\": 35.29,\n \"freezingRainIntensity\": 0,\n \"humidity\": 57.93,\n \"precipitationProbability\": 0,\n \"pressureSurfaceLevel\": 30.21,\n \"rainIntensity\": 0,\n \"sleetIntensity\": 0,\n \"snowIntensity\": 0,\n \"temperature\": 49.73,\n \"temperatureApparent\": 49.73,\n \"uvHealthConcern\": 0,\n \"uvIndex\": 0,\n \"visibility\": 9.94,\n \"weatherCode\": 1000,\n \"windDirection\": 333.88,\n \"windGust\": 19.89,\n \"windSpeed\": 7.04\n }\n },\n {\n \"time\": \"2024-11-02T12:17:00Z\",\n \"values\": {\n \"cloudBase\": null,\n \"cloudCeiling\": null,\n \"cloudCover\": 0.09,\n \"dewPoint\": 35.32,\n \"freezingRainIntensity\": 0,\n \"humidity\": 57.85,\n \"precipitationProbability\": 0,\n \"pressureSurfaceLevel\": 30.21,\n \"rainIntensity\": 0,\n \"sleetIntensity\": 0,\n \"snowIntensity\": 0,\n \"temperature\": 49.8,\n \"temperatureApparent\": 49.8,\n \"uvHealthConcern\": 0,\n \"uvIndex\": 0,\n \"visibility\": 9.94,\n \"weatherCode\": 1000,\n \"windDirection\": 333.88,\n \"windGust\": 19.92,\n \"windSpeed\": 7.09\n }\n },\n {\n \"time\": \"2024-11-02T12:18:00Z\",\n \"values\": {\n \"cloudBase\": null,\n \"cloudCeiling\": null,\n \"cloudCover\": 0.13,\n \"dewPoint\": 35.35,\n \"freezingRainIntensity\": 0,\n \"humidity\": 57.78,\n \"precipitationProbability\": 0,\n \"pressureSurfaceLevel\": 30.21,\n \"rainIntensity\": 0,\n \"sleetIntensity\": 0,\n \"snowIntensity\": 0,\n \"temperature\": 49.87,\n \"temperatureApparent\": 49.87,\n \"uvHealthConcern\": 0,\n \"uvIndex\": 0,\n \"visibility\": 9.94,\n \"weatherCode\": 1000,\n \"windDirection\": 333.88,\n \"windGust\": 19.95,\n \"windSpeed\": 7.13\n }\n },\n {\n \"time\": \"2024-11-02T12:19:00Z\",\n \"values\": {\n \"cloudBase\": null,\n \"cloudCeiling\": null,\n \"cloudCover\": 0.17,\n \"dewPoint\": 35.37,\n \"freezingRainIntensity\": 0,\n \"humidity\": 57.7,\n \"precipitationProbability\": 0,\n \"pressureSurfaceLevel\": 30.21,\n \"rainIntensity\": 0,\n \"sleetIntensity\": 0,\n \"snowIntensity\": 0,\n \"temperature\": 49.93,\n \"temperatureApparent\": 49.93,\n \"uvHealthConcern\": 0,\n \"uvIndex\": 0,\n \"visibility\": 9.94,\n \"weatherCode\": 1000,\n \"windDirection\": 333.88,\n \"windGust\": 19.99,\n \"windSpeed\": 7.18\n }\n },\n {\n \"time\": \"2024-11-02T12:20:00Z\",\n \"values\": {\n \"cloudBase\": null,\n \"cloudCeiling\": null,\n \"cloudCover\": 0.21,\n \"dewPoint\": 35.4,\n \"freezingRainIntensity\": 0,\n \"humidity\": 57.63,\n \"precipitationProbability\": 0,\n \"pressureSurfaceLevel\": 30.21,\n \"rainIntensity\": 0,\n \"sleetIntensity\": 0,\n \"snowIntensity\": 0,\n \"temperature\": 50,\n \"temperatureApparent\": 50,\n \"uvHealthConcern\": 0,\n \"uvIndex\": 0,\n \"visibility\": 9.94,\n \"weatherCode\": 1000,\n \"windDirection\": 333.88,\n \"windGust\": 20.02,\n \"windSpeed\": 7.23\n }\n },\n {\n \"time\": \"2024-11-02T12:21:00Z\",\n \"values\": {\n \"cloudBase\": null,\n \"cloudCeiling\": null,\n \"cloudCover\": 0.26,\n \"dewPoint\": 35.43,\n \"freezingRainIntensity\": 0,\n \"humidity\": 57.56,\n \"precipitationProbability\": 0,\n \"pressureSurfaceLevel\": 30.21,\n \"rainIntensity\": 0,\n \"sleetIntensity\": 0,\n \"snowIntensity\": 0,\n \"temperature\": 50.07,\n \"temperatureApparent\": 50.07,\n \"uvHealthConcern\": 0,\n \"uvIndex\": 0,\n \"visibility\": 9.94,\n \"weatherCode\": 1000,\n \"windDirection\": 333.88,\n \"windGust\": 20.06,\n \"windSpeed\": 7.28\n }\n },\n {\n \"time\": \"2024-11-02T12:22:00Z\",\n \"values\": {\n \"cloudBase\": null,\n \"cloudCeiling\": null,\n \"cloudCover\": 0.3,\n \"dewPoint\": 35.45,\n \"freezingRainIntensity\": 0,\n \"humidity\": 57.48,\n \"precipitationProbability\": 0,\n \"pressureSurfaceLevel\": 30.21,\n \"rainIntensity\": 0,\n \"sleetIntensity\": 0,\n \"snowIntensity\": 0,\n \"temperature\": 50.14,\n \"temperatureApparent\": 50.14,\n \"uvHealthConcern\": 0,\n \"uvIndex\": 0,\n \"visibility\": 9.94,\n \"weatherCode\": 1000,\n \"windDirection\": 333.88,\n \"windGust\": 20.09,\n \"windSpeed\": 7.32\n }\n },\n {\n \"time\": \"2024-11-02T12:23:00Z\",\n \"values\": {\n \"cloudBase\": null,\n \"cloudCeiling\": null,\n \"cloudCover\": 0.34,\n \"dewPoint\": 35.48,\n \"freezingRainIntensity\": 0,\n \"humidity\": 57.41,\n \"precipitationProbability\": 0,\n \"pressureSurfaceLevel\": 30.21,\n \"rainIntensity\": 0,\n \"sleetIntensity\": 0,\n \"snowIntensity\": 0,\n \"temperature\": 50.2,\n \"temperatureApparent\": 50.2,\n \"uvHealthConcern\": 0,\n \"uvIndex\": 0,\n \"visibility\": 9.94,\n \"weatherCode\": 1000,\n \"windDirection\": 333.88,\n \"windGust\": 20.12,\n \"windSpeed\": 7.37\n }\n },\n {\n \"time\": \"2024-11-02T12:24:00Z\",\n \"values\": {\n \"cloudBase\": null,\n \"cloudCeiling\": null,\n \"cloudCover\": 0.38,\n \"dewPoint\": 35.51,\n \"freezingRainIntensity\": 0,\n \"humidity\": 57.33,\n \"precipitationProbability\": 0,\n \"pressureSurfaceLevel\": 30.21,\n \"rainIntensity\": 0,\n \"sleetIntensity\": 0,\n \"snowIntensity\": 0,\n \"temperature\": 50.27,\n \"temperatureApparent\": 50.27,\n \"uvHealthConcern\": 0,\n \"uvIndex\": 0,\n \"visibility\": 9.94,\n \"weatherCode\": 1000,\n \"windDirection\": 333.88,\n \"windGust\": 20.16,\n \"windSpeed\": 7.42\n }\n },\n {\n \"time\": \"2024-11-02T12:25:00Z\",\n \"values\": {\n \"cloudBase\": null,\n \"cloudCeiling\": null,\n \"cloudCover\": 0.43,\n \"dewPoint\": 35.54,\n \"freezingRainIntensity\": 0,\n \"humidity\": 57.26,\n \"precipitationProbability\": 0,\n \"pressureSurfaceLevel\": 30.21,\n \"rainIntensity\": 0,\n \"sleetIntensity\": 0,\n \"snowIntensity\": 0,\n \"temperature\": 50.34,\n \"temperatureApparent\": 50.34,\n \"uvHealthConcern\": 0,\n \"uvIndex\": 0,\n \"visibility\": 9.94,\n \"weatherCode\": 1000,\n \"windDirection\": 333.88,\n \"windGust\": 20.19,\n \"windSpeed\": 7.47\n }\n },\n {\n \"time\": \"2024-11-02T12:26:00Z\",\n \"values\": {\n \"cloudBase\": null,\n \"cloudCeiling\": null,\n \"cloudCover\": 0.47,\n \"dewPoint\": 35.56,\n \"freezingRainIntensity\": 0,\n \"humidity\": 57.19,\n \"precipitationProbability\": 0,\n \"pressureSurfaceLevel\": 30.21,\n \"rainIntensity\": 0,\n \"sleetIntensity\": 0,\n \"snowIntensity\": 0,\n \"temperature\": 50.41,\n \"temperatureApparent\": 50.41,\n \"uvHealthConcern\": 0,\n \"uvIndex\": 0,\n \"visibility\": 9.94,\n \"weatherCode\": 1000,\n \"windDirection\": 333.88,\n \"windGust\": 20.23,\n \"windSpeed\": 7.51\n }\n },\n {\n \"time\": \"2024-11-02T12:27:00Z\",\n \"values\": {\n \"cloudBase\": null,\n \"cloudCeiling\": null,\n \"cloudCover\": 0.51,\n \"dewPoint\": 35.59,\n \"freezingRainIntensity\": 0,\n \"humidity\": 57.11,\n \"precipitationProbability\": 0,\n \"pressureSurfaceLevel\": 30.21,\n \"rainIntensity\": 0,\n \"sleetIntensity\": 0,\n \"snowIntensity\": 0,\n \"temperature\": 50.47,\n \"temperatureApparent\": 50.47,\n \"uvHealthConcern\": 0,\n \"uvIndex\": 0,\n \"visibility\": 9.94,\n \"weatherCode\": 1000,\n \"windDirection\": 333.88,\n \"windGust\": 20.26,\n \"windSpeed\": 7.56\n }\n },\n {\n \"time\": \"2024-11-02T12:28:00Z\",\n \"values\": {\n \"cloudBase\": null,\n \"cloudCeiling\": null,\n \"cloudCover\": 0.55,\n \"dewPoint\": 35.62,\n \"freezingRainIntensity\": 0,\n \"humidity\": 57.04,\n \"precipitationProbability\": 0,\n \"pressureSurfaceLevel\": 30.21,\n \"rainIntensity\": 0,\n \"sleetIntensity\": 0,\n \"snowIntensity\": 0,\n \"temperature\": 50.54,\n \"temperatureApparent\": 50.54,\n \"uvHealthConcern\": 0,\n \"uvIndex\": 0,\n \"visibility\": 9.94,\n \"weatherCode\": 1000,\n \"windDirection\": 333.88,\n \"windGust\": 20.29,\n \"windSpeed\": 7.61\n }\n },\n {\n \"time\": \"2024-11-02T12:29:00Z\",\n \"values\": {\n \"cloudBase\": null,\n \"cloudCeiling\": null,\n \"cloudCover\": 0.6,\n \"dewPoint\": 35.65,\n \"freezingRainIntensity\": 0,\n \"humidity\": 56.96,\n \"precipitationProbability\": 0,\n \"pressureSurfaceLevel\": 30.2,\n \"rainIntensity\": 0,\n \"sleetIntensity\": 0,\n \"snowIntensity\": 0,\n \"temperature\": 50.61,\n \"temperatureApparent\": 50.61,\n \"uvHealthConcern\": 0,\n \"uvIndex\": 0,\n \"visibility\": 9.94,\n \"weatherCode\": 1000,\n \"windDirection\": 333.88,\n \"windGust\": 20.33,\n \"windSpeed\": 7.66\n }\n },\n {\n \"time\": \"2024-11-02T12:30:00Z\",\n \"values\": {\n \"cloudBase\": null,\n \"cloudCeiling\": null,\n \"cloudCover\": 0.64,\n \"dewPoint\": 35.67,\n \"freezingRainIntensity\": 0,\n \"humidity\": 56.89,\n \"precipitationProbability\": 0,\n \"pressureSurfaceLevel\": 30.2,\n \"rainIntensity\": 0,\n \"sleetIntensity\": 0,\n \"snowIntensity\": 0,\n \"temperature\": 50.68,\n \"temperatureApparent\": 50.68,\n \"uvHealthConcern\": 0,\n \"uvIndex\": 0,\n \"visibility\": 9.94,\n \"weatherCode\": 1000,\n \"windDirection\": 333.88,\n \"windGust\": 20.36,\n \"windSpeed\": 7.7\n }\n },\n {\n \"time\": \"2024-11-02T12:31:00Z\",\n \"values\": {\n \"cloudBase\": null,\n \"cloudCeiling\": null,\n \"cloudCover\": 0.68,\n \"dewPoint\": 35.7,\n \"freezingRainIntensity\": 0,\n \"humidity\": 56.82,\n \"precipitationProbability\": 0,\n \"pressureSurfaceLevel\": 30.2,\n \"rainIntensity\": 0,\n \"sleetIntensity\": 0,\n \"snowIntensity\": 0,\n \"temperature\": 50.74,\n \"temperatureApparent\": 50.74,\n \"uvHealthConcern\": 0,\n \"uvIndex\": 0,\n \"visibility\": 9.94,\n \"weatherCode\": 1000,\n \"windDirection\": 333.88,\n \"windGust\": 20.4,\n \"windSpeed\": 7.75\n }\n }\n ]\n }\n}","output":"json","x":480,"y":700,"wires":[["9a8084576d726a90"]]},{"id":"250544b3ed33c940","type":"split","z":"2290795c114cdec3","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","property":"payload","x":500,"y":760,"wires":[["4a2dc9db83aea183"]]},{"id":"9a8084576d726a90","type":"change","z":"2290795c114cdec3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.timelines.minutely","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":760,"wires":[["250544b3ed33c940"]]},{"id":"47b37ec837007416","type":"debug","z":"2290795c114cdec3","name":"full array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1000,"y":820,"wires":[]},{"id":"4a2dc9db83aea183","type":"change","z":"2290795c114cdec3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.values.temperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":760,"wires":[["33a135ea8c88f579"]]},{"id":"33a135ea8c88f579","type":"join","z":"2290795c114cdec3","name":"","mode":"auto","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","useparts":false,"accumulate":"false","timeout":"","count":"","reduceRight":false,"x":860,"y":760,"wires":[["b4f7426eebcbaea3"]]},{"id":"b4f7426eebcbaea3","type":"function","z":"2290795c114cdec3","name":"convert to number prop object","func":"const obj = {}\nfor (let index = 0; index < msg.payload.length; index++) {\n obj[index] = msg.payload[index];\n}\nmsg.payload = obj\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":770,"y":820,"wires":[["47b37ec837007416"]]}]
Or do you want your message1 to contain just 52, message2 to contain 58 etc?
That is exactly what V2 of my demo does
What I didn't understand about the demo flows you provided is that it was all inject nodes whereas I'm getting the data, in JSON form, from a website, so the input is that data, the JSON object data direct from the website.
So with that as my input, I'm trying to get msg.payload.timelines.minutely[x].values.temperature
to output 60 separate messages by iterating x from 1-60.
I can, of course, simply stick 60 Change nodes on the HTTP output and individually have each Change node create a msg.payload - msg.payload.timelines.minutely[1].values.temperature
, msg.payload.timelines.minutely[2].values.temperature
etc. But 60 Change will be a visual nightmare! So I'm looking for a way to have that same outcome but without having the tedium of having to setup 60 Change nodes.
I dont have access to your API data and you did not provide details of how to access it - so I had to do something. It is very common to simulate the final outcome using injects. It is simply a matter of learning how it works and replacing the demo data/inject with your real data. e.g.
msg.payload.timelines.minutely[x].values.temperature
to output 60 separate messages by iterating x from 1-60.
You do realise that is EXACTLY what V2 does?
What I didn't understand about the demo flows you provided is that it was all inject nodes whereas I'm getting the data, in JSON form, from a website, so the input is that data, the JSON object data direct from the website.
Makes no differnecne, these are examples and we do not have your http request node or api key. Replace the injects with http request nodes, or what ever node you are using
So with that as my input, I'm trying to get
msg.payload.timelines.minutely[x].values.temperature
to output 60 separate messages by iterating x from 1-60.
Both Steve and myself have given you example flows that do this. You can identify each message using msg.parts.index, as the split node adds this to each of the 60 outputs. Use the debug node set to complete message object to see all the message properties.
You may benefit from watching the essentials videos
You're saying I can replace the Inject and Sample Data node in V2 with the HTTP data? Okay I didn't understand that. Thanks
But 60 Change will be a visual nightmare! So I'm looking for a way to have that same outcome but without having the tedium of having to setup 60 Change nodes.
The split node will, as the name hints, split your complex message into multiple individual messages.
I think that you need to tell it to split msg.payload.timelines.minutely
Which should give you 60 messages each containing (for example)
payload.values.temperature and a lot of other stuff.
Now wire that node to a change node in which you move msg.payload.values.temperature to msg.payload.
A debug node after that should show you 60 messages: 52, 58, 55 etc
Steve has explained things and asked lots of questions to clarify what you need. Instead of answering, you have basically repeated your original question. It makes it hard to help you