I'm using python request module to get a JSON reponse from 3 different servers. The 2 JSON response look something like these:
JSON Response 1:
{"MaleName1":"John","MaleAge1":"1.40531900","FemaleName1":"Anna","FemaleAge1":"14"}
JSON Response 2:
{"male":[{"name":"John","age":"12"}],"female":[{"name":"Anna","age":"14"}]}
JSON Response 3:
{"male":[["John","12",[]],["Alex","13",[]],["Glenn","12",[]],["Patrick","14",[]],["Gerard","14",[]]],"female":[["Anna","14",[]],["Lena","12",[]],["Martha","13",[]],["Penelope","13",[]],["Brenda","13",[]]]}
My question is what is the correct approach to parse 2nd and 3rd JSON responses so I can print the following desired values:
1st Male Name: John
1st Male Age: 12
1st Female Name: Anna
1st Female Age: 14
For the 1st JSON response, I got no issue getting the desired response by using the float() argument below:
import json, requests
def 1stMaleName():
1stMaleNameData = requests.get('url')
return 1stMaleNameData.json()['MaleName1']
1stMaleNameValue = float(1stMaleName())
Print ("!st Male Name: ", 1stMaleNameValue)