I'm creating an application using python. I make a HTTP request and get a following result:
{
"companies": {
"company": [
{
"createDt": "2014-01-18T00:00:00+01:00",
"dbNazev": "sveatlo_s_r_o_",
"id": "1",
"licenseGroup": "null",
"nazev": "Sveatlo s.r.o.",
"show": "true",
"stavEnum": "ESTABLISHED",
"watchingChanges": "false"
},
{
"createDt": "2014-01-20T00:00:00+01:00",
"dbNazev": "hajocka",
"id": "2",
"licenseGroup": "null",
"nazev": "HájoÄka",
"show": "true",
"stavEnum": "ESTABLISHED",
"watchingChanges": "false"
}
]
}
}
Then I'm processing the data in a for loop. the problem is that the response may also look like this:
{
"companies": {
"company": {
"createDt": "2014-01-18T00:00:00+01:00",
"dbNazev": "sveatlo_s_r_o_",
"id": "1",
"licenseGroup": "null",
"nazev": "Sveatlo s.r.o.",
"show": "true",
"stavEnum": "ESTABLISHED",
"watchingChanges": "false"
}
}
}
Currently I'm checking if it is an array or not after each request like this, but I feel it's not the best way to do this. Could anybody please help me to find a better solution?
Thanks for any answer.
edit: I cannot change the server's response