There are several posts about this subject but I can't make them work with my data.
Given this input
let locations = [
{"Camberwell":
{
"name": "Camberwell",
"latitude": 51.3,
"longitude": -0.5,
"creation": "2023-05-16T12:34:40.068Z",
"lastseen": "2023-05-16T12:34:40.068Z",
"borough": "Southwark"
}
},
{"Seven Dials":
{
"name": "Seven Dials",
"latitude": 51.4,
"longitude": -0.2,
"creation": "2023-05-16T12:35:22.813Z",
"borough": "Camden"
}
}
]
I cannot convert it to pass to a dashboard dropdown as msg.options
[{"Camberwell": "Southwark"}, {"Seven Dials": "Camden"}]
Can someone please show me the way? Either JSONata or function code !
ps the input data could perhaps be created like this, if it makes more sense.
let locations = [
{
"name": "Camberwell",
"latitude": 51.3,
"longitude": -0.5,
"creation": "2023-05-16T12:34:40.068Z",
"lastseen": "2023-05-16T12:34:40.068Z",
"borough": "Southwark"
},
{
"name": "Seven Dials",
"latitude": 51.4,
"longitude": -0.2,
"creation": "2023-05-16T12:35:22.813Z",
"borough": "Camden"
}
]