Thanks James.

I heard of serialization in REST but I haven't played around with it.
That's why I didn't know the exact terms of what I am doing.

On Thu, Dec 28, 2017 at 5:44 AM, James Schneider <[email protected]>
wrote:

>
>
> On Dec 27, 2017 1:02 PM, "tango ward" <[email protected]> wrote:
>
> Follow up question. Apologies for the continuation.
>
> I tried integrating the API from OpenDOTA https://api.opendota.com/api/h
> eroes.
>
> my code:
>
> import requests
> import json
>
> url = requests.get('https://api.opendota.com/api/heroes')
> res = url.json()
>
> when I typed in 'res' in my terminal, it returns a List of dictionaries.
> Now, is it possible to turn this list to a dictionary? Apologies for the
> confusion, I am confuse as well.
>
>
> The terms you are looking for are serialization (converting Python objects
> to JSON) and deserialization (converting JSON to Python objects).
>
> If you're using requests, and you can successfully run the .json() method,
> then you successfully converted the JSON to a native Python structure.
>
> In this case, you are requesting a list of heroes, so you received a list
> back. You'll need to find the hero you want in the list using the standard
> methods of working with Python lists, access that element, and then you'll
> have access to the dict for that hero.
>
> There is probably a way to get a single dict for a specific hero from the
> API, but I'm not familiar with their API structure. You'll need to revert
> to their API documentation to determine the correct URL structure.
>
> -James
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CA%2Be%2BciUVLzj8%2BeZvwJo_tPGLy7-
> f33Nqwv4yf8v8GA3HdwBNEA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUVLzj8%2BeZvwJo_tPGLy7-f33Nqwv4yf8v8GA3HdwBNEA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA6wQLLsH%3D9Vs4ph%3Dh_2Lg1nW3eppgqEn29haJXOLo0YSPPEdQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to