Extract data from multi array from json
Question: I am new to python.I need to extract data from json file.

    
    
    import urllib
    import re
    import json
    text = urllib.urlopen("http://www.acer.com/wjws/ws/gdp/files/en/IN/-/latest/driver/63/-").read()
    result = json.loads(text)  # result is now a dict
    print result['Files']['OS']['Id']
    

I need to extract "Id" field in "OS" in "Files" from above JSON link

I am getting errors as : TypeError: list indices must be integers, not str

Link contains data as

> { "Files": { "Result": "OK", "Language": [ { "Id": "bg", "Title":
> "Bulgarian" },
>  
>  
>             {
>                 "Id": "no",
>                 "Title": "Norwegian"
>             },
>  
>         ],
>         "SearchedLanguage": "en",
>         "OS": [
>             {
>                 "Id": "001",
>                 "Title": "Windows® 2000 Professional"
>             },
>             {
>                 "Id": "098",
>                 "Title": "Windows® 98"
>             },
>             {
>                 "Id": "0ME",
>                 "Title": "Windows® ME"
>             },
>             {
>                 "Id": "X02",
>                 "Title": "Windows® XP 32-bit"
>             },
>             {
>                 "Id": "X05",
>                 "Title": "Windows® XP 64-bit"
>             }
>         ],
>         "File": [
>             {
>                 "Link": "http:\/\/global-
> download.acer.com\/GDFiles\/Driver\/VGA\/VGA_VIA_1.0_w2k.zip?acerid=633676006896131590",
>                 "Category": "VGA",
>  
>             },
>  
>         ]
>     } }
>  


Answer: Change the last line code to,

print result['Files']['OS'][0]['Id']

It will get the first id in OS.

