I'm using Climacell to obtain forecast data which I want to plot in a chart, and despite many attempts over several days, I cannot get the data into the correct format
The api returns an array of about 73 objects taking this format;
[
{
"lat": 53.473035,
"lon": -1.054869,
"precipitation": {
"value": 20,
"units": "mm/hr"
},
"observation_time": {
"value": "2020-07-06T18:40:21.601Z"
}
},
{
"lat": 53.473035,
"lon": -1.054869,
"precipitation": {
"value": 30,
"units": "mm/hr"
},
"observation_time": {
"value": "2020-07-06T18:45:21.601Z"
}
}
Plus 71 other objects
]
and I want to extract the precipitation.value
and the corresponding observation_time.value
(as a unix timestamp), in a format like this;
[
{
"x": 1594060821601,
"y": 20
},
{
"x": 1594061121601,
"y": 30
}
etc, etc
]
I can convert the UTC timestamp to a Unix timestamp by using Date.parse("2020-07-06T18:45:21.601Z")
but definitely failing to get the values out in that format.
Any help would be appreciated.
I've attached an inject node loaded with the array of objects if it helps.
[{"id":"7a5026f6.990af8","type":"inject","z":"a444a9ff.e7a408","name":"Array of objects","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T19:37:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T19:42:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T19:47:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T19:52:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T19:57:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T20:02:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T20:07:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T20:12:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T20:17:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T20:22:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T20:27:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T20:32:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T20:37:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T20:42:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T20:47:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T20:52:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T20:57:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T21:02:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T21:07:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T21:12:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T21:17:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T21:22:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T21:27:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T21:32:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T21:37:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T21:42:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T21:47:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T21:52:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T21:57:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T22:02:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T22:07:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T22:12:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T22:17:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T22:22:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T22:27:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T22:32:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T22:37:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T22:42:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T22:47:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T22:52:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T22:57:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T23:02:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T23:07:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T23:12:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T23:17:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T23:22:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T23:27:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T23:32:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T23:37:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T23:42:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T23:47:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T23:52:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-06T23:57:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T00:02:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T00:07:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T00:12:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T00:17:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T00:22:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T00:27:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T00:32:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T00:37:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T00:42:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T00:47:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T00:52:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T00:57:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T01:02:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T01:07:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T01:12:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T01:17:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T01:22:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T01:27:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T01:32:15.603Z\"}},{\"lat\":53.48034,\"lon\":-1.0105372,\"precipitation\":{\"value\":0,\"units\":\"mm/hr\"},\"observation_time\":{\"value\":\"2020-07-07T01:37:15.603Z\"}}]","payloadType":"json","x":170,"y":3060,"wires":[[]]}]