Jeg ville kanskje gjort noe som dette: (testet i Python 3.8)
Kode
import json
from datetime import datetime
with open("input.json") as ifile:
data = json.loads(ifile.read())
adm_msgs = sorted(
filter(
lambda x: x["from"]["name"] == "Administrasjonen",
data["data"][0]["messages"]["data"]
), key=lambda x: datetime.strptime(x["created_time"], "%Y-%m-%dT%H:%M:%S%z")
)
if "Automatisk svar" in adm_msgs[-1]["message"]:
print("Siste melding var automatisk")