I am trying to filter a JSON array based on a value contained in each of the arrays. Provided some user input, I only want to return relevant values based on the type.

Sample json:

```
{
    "routes": [
        {
            "name": "Golden Shower",
            "type": "Boulder",
            "rating": "V5",
            "stars": 5,
            "starVotes": 131,
            "pitches": ""
        },
        {
            "name": "Girls Only",
            "type": "Sport",
            "rating": "5.10a",
            "stars": 4.9,
            "starVotes": 156,
            "pitches": "1"
        }
    ],
    "success": 1
}

```

I have attempted to use a few variations of a code sample provided on a similar question, but am running in to issues due to slightly more complex data structure. See: [how to filter json array in python](https://stackoverflow.com/questions/27189892/how-to-filter-json-array-in-python)

I have tried a few variations of code. All of the errors center around improper use of indices. Some things I've tried.

```py
routeData = routesByGpsResp.json()
input_dict = routeData
output_dict = [x for x in input_dict if x['type'] == 'Sport']

```

error: sting indices must be integers

```
output_dict = [x for x in input_dict.items() if ['routes'][x]['type'] == 'Sport']

```

error: list indices must be integers or slices, not tuple

I was able to print a list of route names using for statement an index, but cannot seem to figure it out for list comprehension.

```py
for key in range(len(routeData['routes'])):
    print(routeData['routes'][key]['name'])

```

Is list comprehension the wrong way to go here? Should I be using a for statement instead?

Any help is appreciated!