I have a javascript object with the following schema:
[{
face:"n",
values:[
{time:"15:00",value:5}
{time:"15:02",value:6}
]
},{
face:"e",
values:[
{time:"15:01",value:7}
{time:"15:02",value:8}
]
},{
face:"s",
values:[
{time:"15:01",value:7}
{time:"15:02",value:8}
]
},{
face:"w",
values:[
{time:"15:01",value:7}
{time:"15:02",value:8}
]
}]
How to convert it to the following structure:
[
{time:"15:00","n":5,"e":null,"s":null,"w":null},
{time:"15:01","n":null,"e":7,"s":7,"w":7},
{time:"15:02","n":6,"e":8,"s":8,"w":8},
]
- The number of faces will be fixed (north, east, south, west)
- It is possible that some timestamps are missing. In that case we need to fill the value with 'null' (see example above).