How can I pull and use JSON data using javascript?
For example, the URL https://graph.facebook.com/btaylor has the following JSON:
{
"id": "220439",
"name": "Bret Taylor",
"first_name": "Bret",
"last_name": "Taylor",
"link": "http://www.facebook.com/btaylor",
"username": "btaylor",
"gender": "male",
"locale": "en_US"
}
How can I this data into javascript variables?
Not looking to use facebook API or anything dynamic right now, just getting JSON data from a static URL into javascript.
In PHP I could easily do this like:
$contents = file_get_contents($url);
$jsonObj = json_decode($contents);
echo "Name: ".$jsonObj->{'name'};