JSON result parsing

TUA kai.peters at gmail.com
Fri Jul 29 19:45:06 EDT 2016


Calls to my REST api may either return a dict (for single results) or a list of dicts (for multiple results).

I receive these results using the requests library.

I want to retrieve the value for a key 'ID' but only if I have a single result and, obviously, if ID is present.

How can I do this with pythonic elegance?

Thanks for all suggestions!



More information about the Python-list mailing list