I am playing with some air quality data where each results contains at least 2 results. I know that I can limit the loop and get the data from the last entry only, but would have been very nice if I can actually sum the values of the same keys and divide the result by the number of entries, so I can get more precise value.
A problem that I see there is that the key value for P1 and P2 are within the same array so no idea how to sum the two keys separately
The difference between the values in two sets of P1 and P2 keys is coming from the timestamp of the data.
Any idea how can I achieve that?
Here is the JSON data
[{"sensor":{"sensor_type":{"name":"SDS011","manufacturer":"Nova Fitness","id":14},"pin":"1","id":19770},"sensordatavalues":[{"value_type":"P1","value":"250.80","id":6323692330},{"value_type":"P2","value":"68.70","id":6323692332}],"location":{"country":"BG","latitude":"41.9460","altitude":"229.5","longitude":"25.5380","id":10044},"sampling_rate":null,"timestamp":"2019-02-26 14:02:34","id":2977869281},{"sensor":{"sensor_type":{"name":"SDS011","manufacturer":"Nova Fitness","id":14},"pin":"1","id":19770},"sensordatavalues":[{"value_type":"P1","value":"106.87","id":6323721400},{"value_type":"P2","value":"34.80","id":6323721402}],"location":{"country":"BG","latitude":"41.9460","altitude":"229.5","longitude":"25.5380","id":10044},"sampling_rate":null,"timestamp":"2019-02-26 14:05:04","id":2977883059}]