Let's say I have a JSON Object that is this:
{"success":true, "开发者_如何学Cuploaded_url":uploaded_url}
How do I alert("uploaded_url")
?
If it's a JSON file, say file.json
, it would look like this:
$.getJSON("file.json", function(obj) {
alert(obj.uploaded_url);
});
...it really depends how you're loading it, but it's just object.uploaded_url
or object["uploaded_url"]
once you have the object.
If you got a JSON string like this:
var myjson = '{"success":true, "uploaded_url":uploaded_url}'
you need to parse it into an javascript object first. Most convinient way is to use JSON.parse()
which pretty much browsers support nowadays (if not, visit http://www.json.org)
var myobj = JSON.parse(myjson);
alert(myobj.uploaded_url);
精彩评论