1

Let's say I have a JSON Object that is this:

{"success":true, "uploaded_url":uploaded_url}

How do I alert("uploaded_url")?

2

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.