fork download
  1. import json
  2.  
  3. json_string = """{
  4. "data": [
  5. {
  6. "attributes": {
  7. "first_name": "Tester",
  8. "last_name": "Testman",
  9. "other stuff": "stuff"
  10. },
  11. "id": "732887",
  12. "relationships": {
  13. "educations": {
  14. "data": [
  15. {
  16. "id": "605372",
  17. "type": "educations"
  18. },
  19. {
  20. "id": "605371",
  21. "type": "educations"
  22. },
  23. {
  24. "id": "605370",
  25. "type": "educations"
  26. }
  27. ]
  28. }
  29. }
  30. }
  31. ]
  32. }"""
  33.  
  34. candidate_response = json.loads(json_string)
  35.  
  36. candidate_list = []
  37.  
  38. for candidate in candidate_response['data']:
  39. if 'error' not in candidate_response:
  40. for data in candidate['relationships']['educations']['data']:
  41. candidate_list.append(
  42. [
  43. candidate['id'],
  44. candidate['attributes']['first_name'],
  45. candidate['attributes']['last_name'],
  46. data['id']
  47. ]
  48. )
  49.  
  50. print(candidate_list)
  51.  
Success #stdin #stdout 0.02s 7552KB
stdin
Standard input is empty
stdout
[[u'732887', u'Tester', u'Testman', u'605372'], [u'732887', u'Tester', u'Testman', u'605371'], [u'732887', u'Tester', u'Testman', u'605370']]