Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Rashii Henry
Rashii Henry
16,433 Points

Question About Parsing JSON

Does every website have JSON data that can be parsed?

If so, how do you find the correct URL's to parse the data?

2 Answers


Not all websites return JSON, it is only returned if a server has been programmed to do so.

If a website does have a publicly accessible JSON API they will usually provide a developers API guide such as these: NASA

Google Geocoding


Rashii Henry
Rashii Henry
16,433 Points

Okay, so if i website is not programmed to return JSON, shouldn't it return some type of data that can be parsed into a mobile app?

The reason i'm asking is because i want to know things like..

what are the different formats that i can expect a website to return so it can be parsed?

if its not publicly accessible is it illegal to parse data from the website? Do you have to contact the site owner to receive access? things of that nature..

Websites will normally only return HTML, CSS, Javascript etc. You could store the HTML within an app and filter though the elements to find the sections you wanted. using such libraries as:

These allow you to filter the html and extract the elements you want to use, however you run the risk of the websites html structure changing and breaking your app. Also I'm not sure how this would work with websites that utilise AJAX e.g. Single page websites.

Data provided by a website(API ) is usually available as either:

Both formats are easily parsed and many API's offer both.

Most API's are secured against unauthorised use and abuse through the use of API's keys which you pass within the http requests. These keys are usually obtained from the API developers.

Hope this helps.