I have a JSON file. I want to find the length of the JSON object where one key-value pair is similar. Like,
https://api.myjson.com/bins/h5mgv
[
{
"receive_date": "2013-11-04",
"responses": "2",
"name": "west"
},
{
"receive_date": "2013-11-04",
"responses": "8668",
"name": "west"
},
{
"receive_date": "2013-11-13",
"responses": "121",
"name": "east"
}
]
In the above example, length is 2 where "name": "west"
and length is 1 where "name": "east"
. I want to iterate through the JSON and find the identical values for the key name
using Javascript. Output should look like,
east : 1
west : 2
By using length()
I can find the length of whole JSON but what is recommended way to find the length for identical key values.