title: Search json with Python and return a list
body: <p>I want to search a json file for word "Leak" and the part after "for service" of each line to a list and use that list for some comparison later. </p>
  
  <p>I have written a bit of code but it doesn't work quite as I want it. I don't know how to add the part that I want only to save what comes after "for service" to my code</p>
  
  <pre><code>def searchReport(report):
          json_data=open(report)
          jenkinsReport = json.load(json_data)
          json_data.close()
          for id in jenkinsReport:
                  memoryLeak=[]
                  if "Leak" in jenkinsReport[id]: 
                          memoryLeak.append("Leak")
          return memoryLeak
  
  </code></pre>
  
  <p>here is the part of json file I want to parse </p>
  
  <pre><code>{
  name: "MemorySnapshotSuite.2",
  description: null,
  is_critical: false,
  start_time: "2019-04-16T10:42:44.043287Z",
  end_time: "2019-04-16T10:42:53.306027Z",
  elapsed_time: 9.262739658355713,
  state: "PASS",
  cases: [
  {
  name: "MemorySnapshot.2",
  description: null,
  is_critical: false,
  start_time: "2019-04-16T10:42:44.043441Z",
  end_time: "2019-04-16T10:42:53.305560Z",
  elapsed_time: 9.26211929321289,
  state: "FAIL",
  steps: [
  {
  description: "...PiNS Sanity Take Memory Snapshot",
  start_time: "2019-04-16T10:42:44.043474Z",
  end_time: "2019-04-16T10:42:45.044551Z",
  elapsed_time: 1.0010769367218018
  },
  {
  description: "Leak of 4884K detected for service alarm-mgr",
  start_time: "2019-04-16T10:42:52.303103Z",
  end_time: "2019-04-16T10:42:52.303136Z",
  elapsed_time: 0.00003218650817871094
  },
  {
  description: "Leak of 2504K detected for service rls",
  start_time: "2019-04-16T10:42:52.303148Z",
  end_time: "2019-04-16T10:42:52.303174Z",
  elapsed_time: 0.000026702880859375
  },
  {
  description: "Leak of 1708K detected for service device-controller",
  start_time: "2019-04-16T10:42:52.303182Z",
  end_time: "2019-04-16T10:42:52.303204Z",
  elapsed_time: 0.000021219253540039062
  },
  {
  description: "Leak of 6660K detected for service slot-mgr",
  start_time: "2019-04-16T10:42:52.303211Z",
  end_time: "2019-04-16T10:42:52.303273Z",
  elapsed_time: 0.00006198883056640625
  },
  {
  description: "Leak of 6916K detected for service security-mgr",
  start_time: "2019-04-16T10:42:52.303284Z",
  end_time: "2019-04-16T10:42:52.303309Z",
  elapsed_time: 0.000025272369384765625
  },
  {
  description: "Leak of 13356K detected for service snmp-card-ra",
  start_time: "2019-04-16T10:42:52.303322Z",
  end_time: "2019-04-16T10:42:52.303400Z",
  elapsed_time: 0.00007796287536621094
  },
  {
  description: "Leak of 2680K detected for service port-manager",
  start_time: "2019-04-16T10:42:52.303427Z",
  end_time: "2019-04-16T10:42:52.303967Z",
  elapsed_time: 0.0005402565002441406
  },
  {
  description: "Memory summary: { "status": "ok", "data": { "ciena-common-dirsvc:domain-instance": [ { "instance-name": "scaler-serv", "pid": 5457, "memory-usage": "24584" }, { "instance-name": "topo-manager", "pid": 5150, "memory-usage": "20324" }, { "instance-name": "template-service", "pid": 3887, "memory-usage": "32504", "memory-diff": 528 }, { "instance-name": "alarm-mgr", "pid": 3878, "memory-usage": "24832", "memory-diff": 4884, "leak": true }, { "instance-name": "card-mgr", "pid": 3852, "memory-usage": "20836", "memory-diff": 264 }, { "instance-name": "license-svc", "pid": 3850, "memory-usage": "21964", "memory-diff": 0 }, { "instance-name": "comms-mgr", "pid": 3847, "memory-usage": "21172", "memory-diff": 264 }, { "instance-name": "configuration-mgr", "pid": 3842, "memory-usage": "17992", "memory-diff": 0 }, { "instance-name": "rls", "pid": 3839, "memory-usage": "45568", "memory-diff": 2504, "leak": true }, { "instance-name": "dns-mgr", "pid": 3838, "memory-usage": "19320", "memory-diff": 0 }, { "instance-name": "fiber-loss-service", "pid": 5510, "memory-usage": "20736" }, { "instance-name": "facility-manager", "pid": 3826, "memory-usage": "20860", "memory-diff": 528 }, { "instance-name": "software-mgr-ce", "pid": 3822, "memory-usage": "18352", "memory-diff": 0 }, { "instance-name": "device-controller", "pid": 3818, "memory-usage": "25900", "memory-diff": 1708, "leak": true }, { "instance-name": "channel-ctrl-svc", "pid": 3814, "memory-usage": "19616", "memory-diff": 0 }, { "instance-name": "pfg-manager", "pid": 3809, "memory-usage": "22840", "memory-diff": 264 }, { "instance-name": "shelf-mgr", "pid": 3806, "memory-usage": "23152", "memory-diff": 264 }, { "instance-name": "slot-mgr", "pid": 3799, "memory-usage": "50196", "memory-diff": 6660, "leak": true }, { "instance-name": "comms-apps-mgr", "pid": 3798, "memory-usage": "18604", "memory-diff": 0 }, { "instance-name": "rls-mgr", "pid": 3797, "memory-usage": "20508", "memory-diff": 792 }, { "instance-name": "lldp-mgr", "pid": 3795, "memory-usage": "20888", "memory-diff": 232 }, { "instance-name": "otdr-svc", "pid": 3793, "memory-usage": "23152", "memory-diff": 0 }, { "instance-name": "oms-topo-svc", "pid": 3789, "memory-usage": "27876", "memory-diff": 636 }, { "instance-name": "dependency-mgr", "pid": 3786, "memory-usage": "18140", "memory-diff": 0 }, { "instance-name": "demo-mgr", "pid": 3780, "memory-usage": "18724", "memory-diff": 0 }, { "instance-name": "dhcp-mgr", "pid": 3762, "memory-usage": "19988", "memory-diff": 96 }, { "instance-name": "wss-controller", "pid": 3755, "memory-usage": "20000", "memory-diff": 0 }, { "instance-name": "security-mgr", "pid": 3752, "memory-usage": "31616", "memory-diff": 6916, "leak": true }, { "instance-name": "6500r-system", "pid": 3751, "memory-usage": "19208", "memory-diff": 0 }, { "instance-name": "data-collector", "pid": 3748, "memory-usage": "20764", "memory-diff": 700 }, { "instance-name": "neighbour-manager", "pid": 3746, "memory-usage": "20068", "memory-diff": 0 }, { "instance-name": "snmp-card-ra", "pid": 3743, "memory-usage": "60436", "memory-diff": 13356, "leak": true }, { "instance-name": "graph-serv", "pid": 3742, "memory-usage": "19068", "memory-diff": 0 }, { "instance-name": "cpu", "pid": 3740, "memory-usage": "20688", "memory-diff": 260 }, { "instance-name": "software-mgr", "pid": 3739, "memory-usage": "22588", "memory-diff": 0 }, { "instance-name": "routing-mgr", "pid": 3738, "memory-usage": "20392", "memory-diff": 0 }, { "instance-name": "port-manager", "pid": 3737, "memory-usage": "24260", "memory-diff": 2680, "leak": true }, { "instance-name": "software-mgr-ctmp", "pid": 3735, "memory-usage": "19240", "memory-diff": 0 }, { "instance-name": "logging-mgr", "pid": 3732, "memory-usage": "18660", "memory-diff": 0 }, { "instance-name": "protection-svc", "pid": 3730, "memory-usage": "20364", "memory-diff": 320 }, { "instance-name": "ztp-mgr", "pid": 3723, "memory-usage": "22544", "memory-diff": 164 } ] } }",
  start_time: "2019-04-16T10:42:52.303998Z",
  end_time: "2019-04-16T10:42:52.304475Z",
  elapsed_time: 0.0004775524139404297
  }
  ],
  errors: [
  {
  type: "BasicError",
  raise_time: "2019-04-16T10:42:52.304459Z",
  message: "Leaks detected"
  }
  ]
  }
  ]
  }
  
  </code></pre>
  
  <p>EDIT: The expected output would be a list </p>
  
  <pre><code>memoryLeak = [alarm-mgr, rls, device-controller, slot-mgr, security-mgr, snmp-card-ra, port-manager]
  
  </code></pre>