I built a dashboard some months ago to analyse local covid data and display it in a way which was quick & easy to digest by my family.
But in the past 6 months, PHE (Public Heath England) have changed the format of their data 3 times now causing me to change chart formats, calculations etc, which is quite a lot of work, testing etc.
So instead of changing my flow around, I think it would be probably easier to change the incoming data format to the previous format, before feeding it into my flow.
However, easier said than done!
My local data covers 39 smaller areas (MSOA's) which I analyse individually, and the 'new' format can be seen from this small flow;
[{"id":"598b83c3.a07d0c","type":"inject","z":"1aed9202.b5cf2e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":600,"wires":[["a13779db.f16d38"]]},{"id":"a13779db.f16d38","type":"http request","z":"1aed9202.b5cf2e","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://api.coronavirus.data.gov.uk/v2/data?areaType=msoa&areaCode=E08000017&metric=newCasesBySpecimenDateRollingSum&format=json","tls":"","persist":false,"proxy":"","authType":"","x":310,"y":600,"wires":[["658e03b2.14f1cc"]]},{"id":"658e03b2.14f1cc","type":"json","z":"1aed9202.b5cf2e","name":"","property":"payload","action":"","pretty":false,"x":470,"y":600,"wires":[["66470546.8437dc"]]},{"id":"66470546.8437dc","type":"debug","z":"1aed9202.b5cf2e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":640,"y":600,"wires":[]}]
..which comprises an array of 1482 objects.
I would like to get that data into a single array of 39 objects, each object representing the complete data for that smaller area (MSOA), so for example 'Moorends' or 'Rossington', etc, so each object in the array would look like this;
{
"name":"Moorends",
"cases":[
{
"date":"2020-11-14",
"rollingSum":11
},
{
"date":"2020-11-21",
"rollingSum":15
},
{
"date":"2020-11-28",
"rollingSum":5
}
]
}
- The 'cases' arrays contain about 38 objects each - I've deleted some for ease of displaying in the example above.
- "rollingSum" has now been renamed "newCasesBySpecimenDateRollingSum:"
- I don't need any of the other data.
I've been trying to do this with jsonata all night, but all I've managed so far is a headache! Any help would be appreciated.