Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. import json
  2.  
  3.  
  4. def run():
  5. """Load data.json file and put into format."""
  6. with open("data.json", "r") as f:
  7. contents = json.loads(f.read())
  8. for cls in contents.get("classes", []):
  9. class_name = cls.get("name")
  10. for spec in cls.get("specializations"):
  11. spec_name = spec.get("name")
  12. for ability in spec.get("abilities"):
  13. name = ability.get('name')
  14. ab_id = ability.get('id')
  15. image_url = ability.get('imageUrl')
  16. print(f"Class: {class_name} - {spec_name}\nName: {name}\nId: {ab_id}\nImageUrl: {image_url}\n")
  17.  
  18. if __name__ == '__main__':
  19. run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement