Get a text file specific field issue
Question: I am working on python in order to use data mining on social media to analysis
data . Now I have written a code which gives me information about Facebook
most liked pages and I have stored information on a text file called
`"pages.txt"` the following is a snapshot of my text file content :

    
    
    {
     "paging": {
      "next": "https://graph.facebook.com/search?limit=1&type=page&q=%26&locale=ar_AR&access_token=CAACEdEose0cBAFxVPV6lJ43O6MABoxVrrHlb01rBNmpVf8ZCK0M1QlsEJ6yRZBWlzjf0vA1eX6YdwNHF2TLZBsECdg6Q8mI3BH3n5QTMsi55KtkCtOCd36AVxjZA7PXBL3mZA6FsLZCNp9IZCItCI4YVhCeikubnwCLpE0nSTOcKXR8DUzcZA4qZCBW92yoCDFk2z0eZBNSUU6lgZDZD&offset=1&__after_id=6127898346"
     }, 
     "data": [
      {
       "category": "\u0627\u0644\u062a\u0639\u0644\u064a\u0645", 
       "name": "The London School of Economics and Political Science - LSE", 
       "category_list": [
        {
         "id": "108051929285833", 
         "name": "\u0627\u0644\u0643\u0644\u064a\u0629 \u0648\u0627\u0644\u062c\u0627\u0645\u0639\u0629"
        }, 
        {
         "id": "187751327923426", 
         "name": "\u0645\u0646\u0638\u0645\u0629 \u062a\u0639\u0644\u064a\u0645\u064a\u0629"
        }
       ], 
       "id": "6127898346"
      }
     ]
    }
    

Now I am wondering how can I get a specific field from it (e.g "id":
"6127898346" ) ? I have tried a lot but I couldn't find a way to do . I have
written this so far :

    
    
    ins = open( "pages.txt", "r" )
    values = []
    for line in ins:   
        values.append(line) 
    
    ins.close()
    print values
    

but this gives me the whole line any help?


Answer: This is JSON. You can get your data by loading it with the `json` module:

    
    
    import json
    with open(your_file).read() as content:
        data = json.loads(content)
        # manipulate your data
    

`data` will be ordinary Python data structures such as nested lists, dict,
strings and int, so you can manipulate them the usual way.

