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

iOS Build a Blog Reader iPhone App Getting Data from the Web Downloading and Parsing JSON Data

Tony Atkinson
Tony Atkinson
4,498 Points

JSON Data Requests In General From a Webiste or Blog That's not Mine

I'm having a little bit of a hard time understanding how to request JSON data from a website, or if that is even the way to put it. I completely understand how parsing the data works once the data is stored into an object, but the URL that treehouse provides already has the JSON data laid out, and does not explain how this data could be gathered from the blog website itself. Say I wanted to gather the JSON data from a wordpress website, or any other blog, how would I go about doing so within objective C, if all I had was the basic URL to start with?

2 Answers

Patrick Cooney
Patrick Cooney
12,216 Points

You can't write client side code that will make a website respond with JSON. That is entirely a server side task. To get JSON back from a website the website you are connecting to has to have the ability to serve a JSON response. Not all sites have this. Usually you will have to go to the developer section of a website to find their API documentation, if they have one at all.

Tony Atkinson
Tony Atkinson
4,498 Points

Ah, that makes complete sense, thanks for the help!

Patrick Cooney
Patrick Cooney
12,216 Points

No problem. I should have added from the start, if you're looking to do this for your own website you can watch some of the rails or PHP videos here to learn the basics then google how to serve JSON responses.

Alan Fisher
Alan Fisher
1,612 Points

I'm having the same problem, I am currently building a blog reader for a wordpress created website. what is the best way to get the Json data? any help would be great

Patrick Cooney
Patrick Cooney
12,216 Points

If you're talking about a wordpress website you created you can look into plugins that serve a JSON response. I think those are a thing and I'm not just making it up. If you don't own the website then you're sort of out of luck on this. That is unless the owner would be willing to install one of those plugins for you.