0

I'm having trouble with getting the variables out of this JSON URL:

{
"meta":{
    "status":200,
    "msg":"OK"
    },      
"response":{
    "blog":{
        "title":"GideonPARANOID",
        "posts":5018,
        "name":"gideonparanoid",
        "url":"http:\/\/gideonparanoid.tumblr.com\/",
        "updated":1336919325,
        "description":"I study computer science at Aberystwyth, though I call Manchester home. I'm vegetarian, & take an interest in photography, gaming & cycling.",
        "ask":true,
        "ask_anon":true
        }
    }
}

I've been successful with using a modified version of the JavaScript given in the first answer here. I'm fairly unfamiliar with JSON, so I'm not sure about how to apply that properly - I've Googled for a good two hours, to no avail.

My latest attempt still doesn't deliver anything.

I'm using a sample API key from Tumblr's API given here.

Any help would be appreciated, thanks.

2 Answers 2

2

Perhaps, var result = JSON.parse(jsonString)?

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

Comments

1

try JSON.parse(json_string).

Example:

var json_string = '{ "meta" : { "msg":"OK"} }';
var o = JSON.parse(json_string);
o.meta // {msg:'OK'}
o.meta.msg // 'OK'

And that's not a URL, that's JSON data.

2 Comments

That's invalid JSON. You need to put quotes around the keys, like this: '{"meta":{"msg": "OK"}}'
It was a demonstration, but thanks for pointing out. I will correct it, but it would be better to correct it yourself, I always do that (makes me feel better:)).

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.