Guest User

Untitled

a guest
Nov 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. {
  2. 'locationId': 'location1',
  3. 'name': 'Name',
  4. 'type': 'Ward',
  5. 'patientId': None,
  6. 'children': [{
  7. 'locationId': 'Child_location2',
  8. 'name': 'Name',
  9. 'type': 'Bed',
  10. 'patientId': None,
  11. 'children': [{
  12. 'locationId': 'Child_Child_location3',
  13. 'name': 'Name',
  14. 'type': 'HospitalGroup',
  15. 'patientId': None,
  16. 'children': None
  17. }]
  18. }, {
  19. 'locationId': 'location4',
  20. 'name': 'Name',
  21. 'type': 'Hospital',
  22. 'patientId': None,
  23. 'children': None
  24. }, {
  25. 'locationId': 'location5',
  26. 'name': 'Name',
  27. 'type': 'Bed',
  28. 'patientId': None,
  29. 'children': None
  30. }, {
  31. 'locationId': 'location6',
  32. 'name': 'Name',
  33. 'type': 'Bed',
  34. 'patientId': None,
  35. 'children': None
  36. }, {
  37. 'locationId': 'location27',
  38. 'name': 'Name',
  39. 'type': 'Bed',
  40. 'patientId': None,
  41. 'children': None
  42. }]
  43. }
  44.  
  45. import requests
  46. def Get_Child(URL, Name):
  47. headers = {
  48. 'accept': 'text/plain',
  49. }
  50.  
  51. response = requests.get(
  52. URL + Name,
  53. headers=headers)
  54. json_data = response.json()
  55. print (json_data)
  56. list = []
  57. for locationId in json['locationId']:
  58. list.append(locationId)
  59. for children in locationId['children']:
  60. list.append(children)
Add Comment
Please, Sign In to add comment