0

This may be really simple but my programming skills in my python are awful

I have a large JSON file that I got from a API.

I need to find all the applications the (top level of json) for everything with a certain value

{
  "app_id": XXXXX,
  "name": "Batman Test App for Application CI",
  "team_name": "XXXXXX",
  "release_train": "Operations Engineering",
},

Above is example of the JSON, I need to find everything in the JSON that has a team_name: myval or everything that has release_train: my value.

I hope that makes sense.

I have loaded the json.load() makes the content a dictionary but I am still trying to figure out the best way to do this.

Like I said this seems straight forward to me but I am having the hardest time figuring it out.

martineau
  • 119,623
  • 25
  • 170
  • 301

1 Answers1

0

A option would be just filter out everyting else that you don't need. You could leverage a dict comprehension for this. For example:

import json
json_as_dict = json.loads(your_json)
filtered = {key:value for json_as_dict.items() if key == "team_name" and value == "myval" or key == "release_train" and value == "my value"}
Bierbarbar
  • 1,399
  • 15
  • 35