Given an array I want to aggregate average value of rating field for all objects grouped by name field in JSON i.e quality and value.
Expected output :
quality - avg rating 2.5
value - avg rating 3
I have an array similar to as given below:
array : [
{
"name": "quality",
"rating": 4,
"range": 5
},
{
"name": "value",
"rating": 4,
"range": 5
},
{
"name": "quality",
"rating": 1,
"range": 5
},
{
"name": "value",
"rating": 2,
"range": 5
}
]