I am using below code to filter the data of json list.
new_list = list()
for lot in json_ls:
recs = lot.get('recipients')
lot_recipients = [rec for rec in recs if rec.get("code") == "user1"]
if lot_recipients:
new_list.append({"lot_number": lot.get('lot_number'),
"recipients": lot_recipients})
It filter the data where code == "user1"
However I need to filter the data if code is either having "user1" or "error". All recipients who is having code is "user1" or "error" for each lot.