FYI: Getting a good look at JSON feeds


#1

I just want to throw this out there, in case anyone would like to get a look at what JSON data looks like. I tweaked the URL to the iTunes Music Store’s JSON feed so that it would only return 1 item, downloaded the response to a text file on my desktop, and then opened it in an online pretty printer (that I found through Google) to get an idea of what is being returned from the request.

So, tweak the URL:

Copy that into your Clipboard and open up Terminal. On the command line, change into your Desktop, and use curl to download the file, feeding it the URL from the Clipboard:

> cd Desktop
> curl -o json_snippet.txt "http://itunes.apple.com/us/rss/topsongs/limit=1/json"

I then opened that in a text editor, copied the entire contents to the Clipboard, and launched Safari. I then opened up the following web page:

Once at that page, you can paste the contents of the Clipboard (the JSON text) and hit the button “Pretty Print JSON”. You’ll see the data printed out with readable indentation in your browser.

Enjoy!


#2

You can also print it out in X-Code. :slight_smile:

Set a breakpoint (e.g. inside the method:

in RSSChannel.m)

Debug Area ==> Variables View ==> right-click on dictionary “d” ==> select "Print description of ‘d’ ==> View output in the console!


#3

[quote=“Crumble”]You can also print it out in X-Code. :slight_smile:

Set a breakpoint (e.g. inside the method:

in RSSChannel.m)

Debug Area ==> Variables View ==> right-click on dictionary “d” ==> select "Print description of ‘d’ ==> View output in the console![/quote]

Lots of ways to accomplish this… Here’s another:

Add a breakpoint below the call to readFromJSONDictionary
Create Log Message Action with parameters %H:%B (Only if you want to show # of times called & function name)
Create Debugger Command with parameters po d (This shows the actual JSON)

(The data will be output to your Xcode Console and can be copied from there)