import re import requests response = requests.get(url='https://d3fend.mitre.org/ontologies/d3fend.json') ds = response.json() print(re.findall('(?<=:)[^\]]+',ds["@graph"][10]["@type"][1])) print(re.findall('(?<=:)[^\]]+',ds["@graph"][10]["rdfs:isDefinedBy"]["@id"])) print(re.findall('(?<=:)[^\]]+',ds["@graph"][10]["rdfs:subClassOf"][1]["@id"]))