OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to get JSON from URL in JavaScript?

  • Thread starter Thread starter Yiğit Doğuş Özçelik
  • Start date Start date
Y

Yiğit Doğuş Özçelik

Guest
This URL returns JSON:

Code:
{
  query: {
    count: 1,
    created: "2015-12-09T17:12:09Z",
    lang: "en-US",
    diagnostics: {},
    ...
  }
}

I tried this, and it didn't work:

Code:
responseObj = readJsonFromUrl('http://query.yahooapis.com/v1/publ...');
var count = responseObj.query.count;

console.log(count) // should be 1

How can I get a JavaScript object from this URL's JSON response?

<p><a href="http://query.yahooapis.com/v1/publi...e://datatables.org/alltableswithkeys&callback" rel="noreferrer">This URL</a> returns JSON:</p>

<pre><code>{
query: {
count: 1,
created: "2015-12-09T17:12:09Z",
lang: "en-US",
diagnostics: {},
...
}
}
</code></pre>

<p>I tried this, and it didn't work:</p>

<pre><code>responseObj = readJsonFromUrl('http://query.yahooapis.com/v1/publ...');
var count = responseObj.query.count;

console.log(count) // should be 1
</code></pre>

<p>How can I get a JavaScript object from this URL's JSON response?</p>
 
Top