itunesStoreのWebAPI利用方法 ( jsonデータ構造)

今回はjsonデータのパース方法を紹介する前に、itunesStoreから返ってくるjsonデータの構造について話をしたいと思います。

前々回の最後にも書きましたが、返ってくるjsonデータは以下の通りです。

{
 "resultCount":5,
 "results": [
{"wrapperType":"track", "kind":"song", "artistId":32940, "collectionId":14908862, "trackId":14908897, "artistName":"Michael Jackson", "collectionName":"The Very Best of Michael Jackson With the Jackson 5", "trackName":"Ben", "collectionCensoredName":"The Very Best of Michael Jackson With the Jackson 5", "trackCensoredName":"Ben", "artistViewUrl":"http://itunes.apple.com/jp/artist/michael-jackson/id32940?uo=4", "collectionViewUrl":"http://itunes.apple.com/jp/album/ben/id14908862?i=14908897&uo=4", "trackViewUrl":"http://itunes.apple.com/jp/album/ben/id14908862?i=14908897&uo=4", "previewUrl":"http://a1410.phobos.apple.com/us/r30/Music/b7/f8/a5/mzi.jsdjptmz.aac.p.m4p", "artworkUrl60":"http://a1.phobos.apple.com/us/r2000/013/Features/ab/4b/d8/dj.dmlvbjtv.60x60-50.jpg", "artworkUrl100":"http://a1.phobos.apple.com/us/r2000/013/Features/ab/4b/d8/dj.dmlvbjtv.100x100-75.jpg", "collectionPrice":1050.00000, "trackPrice":150.00000, "collectionExplicitness":"notExplicit", "trackExplicitness":"notExplicit", "discCount":1, "discNumber":1, "trackCount":21, "trackNumber":11, "trackTimeMillis":167333, "country":"JPN", "currency":"JPY", "primaryGenreName":"R&B/Soul"}, 
{"wrapperType":"track", "kind":"song", "artistId":32940, "collectionId":14908862, "trackId":14908915, "artistName":"Michael Jackson", "collectionName":"The Very Best of Michael Jackson With the Jackson 5", "trackName":"One Day In Your Life", "collectionCensoredName":"The Very Best of Michael Jackson With the Jackson 5", "trackCensoredName":"One Day In Your Life", "artistViewUrl":"http://itunes.apple.com/jp/artist/michael-jackson/id32940?uo=4", "collectionViewUrl":"http://itunes.apple.com/jp/album/one-day-in-your-life/id14908862?i=14908915&uo=4", "trackViewUrl":"http://itunes.apple.com/jp/album/one-day-in-your-life/id14908862?i=14908915&uo=4", "previewUrl":"http://a71.phobos.apple.com/us/r30/Music/bf/ab/78/mzi.tsgagpbx.aac.p.m4p", "artworkUrl60":"http://a1.phobos.apple.com/us/r2000/013/Features/ab/4b/d8/dj.dmlvbjtv.60x60-50.jpg", "artworkUrl100":"http://a1.phobos.apple.com/us/r2000/013/Features/ab/4b/d8/dj.dmlvbjtv.100x100-75.jpg", "collectionPrice":1050.00000, "trackPrice":150.00000, "collectionExplicitness":"notExplicit", "trackExplicitness":"notExplicit", "discCount":1, "discNumber":1, "trackCount":21, "trackNumber":17, "trackTimeMillis":257427, "country":"JPN", "currency":"JPY", "primaryGenreName":"R&B/Soul"}, 
{"wrapperType":"track", "kind":"song", "artistId":32940, "collectionId":14908862, "trackId":14908883, "artistName":"Michael Jackson", "collectionName":"The Very Best of Michael Jackson With the Jackson 5", "trackName":"Got to Be There", "collectionCensoredName":"The Very Best of Michael Jackson With the Jackson 5", "trackCensoredName":"Got to Be There", "artistViewUrl":"http://itunes.apple.com/jp/artist/michael-jackson/id32940?uo=4", "collectionViewUrl":"http://itunes.apple.com/jp/album/got-to-be-there/id14908862?i=14908883&uo=4", "trackViewUrl":"http://itunes.apple.com/jp/album/got-to-be-there/id14908862?i=14908883&uo=4", "previewUrl":"http://a946.phobos.apple.com/us/r30/Music/af/93/28/mzi.iuqjwwgq.aac.p.m4p", "artworkUrl60":"http://a1.phobos.apple.com/us/r2000/013/Features/ab/4b/d8/dj.dmlvbjtv.60x60-50.jpg", "artworkUrl100":"http://a1.phobos.apple.com/us/r2000/013/Features/ab/4b/d8/dj.dmlvbjtv.100x100-75.jpg", "collectionPrice":1050.00000, "trackPrice":150.00000, "collectionExplicitness":"notExplicit", "trackExplicitness":"notExplicit", "discCount":1, "discNumber":1, "trackCount":21, "trackNumber":7, "trackTimeMillis":204867, "country":"JPN", "currency":"JPY", "primaryGenreName":"R&B/Soul"}, 
{"wrapperType":"track", "kind":"song", "artistId":32940, "collectionId":14908862, "trackId":14908889, "artistName":"Michael Jackson", "collectionName":"The Very Best of Michael Jackson With the Jackson 5", "trackName":"Ain't No Sunshine", "collectionCensoredName":"The Very Best of Michael Jackson With the Jackson 5", "trackCensoredName":"Ain't No Sunshine", "artistViewUrl":"http://itunes.apple.com/jp/artist/michael-jackson/id32940?uo=4", "collectionViewUrl":"http://itunes.apple.com/jp/album/aint-no-sunshine/id14908862?i=14908889&uo=4", "trackViewUrl":"http://itunes.apple.com/jp/album/aint-no-sunshine/id14908862?i=14908889&uo=4", "previewUrl":"http://a1221.phobos.apple.com/us/r30/Music/77/cc/4e/mzi.wmtnxrdl.aac.p.m4p", "artworkUrl60":"http://a1.phobos.apple.com/us/r2000/013/Features/ab/4b/d8/dj.dmlvbjtv.60x60-50.jpg", "artworkUrl100":"http://a1.phobos.apple.com/us/r2000/013/Features/ab/4b/d8/dj.dmlvbjtv.100x100-75.jpg", "collectionPrice":1050.00000, "trackPrice":150.00000, "collectionExplicitness":"notExplicit", "trackExplicitness":"notExplicit", "discCount":1, "discNumber":1, "trackCount":21, "trackNumber":9, "trackTimeMillis":252800, "country":"JPN", "currency":"JPY", "primaryGenreName":"R&B/Soul"}, 
{"wrapperType":"track", "kind":"song", "artistId":32940, "collectionId":14908862, "trackId":14908886, "artistName":"Michael Jackson", "collectionName":"The Very Best of Michael Jackson With the Jackson 5", "trackName":"Rockin' Robin", "collectionCensoredName":"The Very Best of Michael Jackson With the Jackson 5", "trackCensoredName":"Rockin' Robin", "artistViewUrl":"http://itunes.apple.com/jp/artist/michael-jackson/id32940?uo=4", "collectionViewUrl":"http://itunes.apple.com/jp/album/rockin-robin/id14908862?i=14908886&uo=4", "trackViewUrl":"http://itunes.apple.com/jp/album/rockin-robin/id14908862?i=14908886&uo=4", "previewUrl":"http://a448.phobos.apple.com/us/r30/Music/e7/f4/12/mzi.otyhktrs.aac.p.m4p", "artworkUrl60":"http://a1.phobos.apple.com/us/r2000/013/Features/ab/4b/d8/dj.dmlvbjtv.60x60-50.jpg", "artworkUrl100":"http://a1.phobos.apple.com/us/r2000/013/Features/ab/4b/d8/dj.dmlvbjtv.100x100-75.jpg", "collectionPrice":1050.00000, "trackPrice":150.00000, "collectionExplicitness":"notExplicit", "trackExplicitness":"notExplicit", "discCount":1, "discNumber":1, "trackCount":21, "trackNumber":8, "trackTimeMillis":154107, "country":"JPN", "currency":"JPY", "primaryGenreName":"R&B/Soul"}]
}

最初の二行に、"resultCount"と"results"という記述があります。
言葉から想像できるように、

"resultCount":取得したデータの数
"results":実際のデータ

となります。

json-framworkでデータをパースする際には、"results"が主な対象です。
"results"の中身を分かる範囲で説明するとこんな感じです。

"results"の範囲:[]
各データの範囲:{}
各データの要素:,区切り
要素:"key:value"で表現

各要素の説明(わかる範囲で)
"wrapperType":オブジェクトの名前(track, collection, artist) 
"kind":コンテンツの種類(book, album, coached-audio, feature-movie, interactive-booklet, music-video, pdfpodcast, podcast-episode, software-package, song, tv-episode, artist), 
"artistId":アーティストid, 
"collectionId":コレクションid,
"trackId":曲id, 
"artistName":アーティスト名,
"collectionName":アルバム名など, 
"trackName":曲名, 
"collectionCensoredName":アルバム名?, 
"trackCensoredName":曲名?, 
"artistViewUrl":アーティスト紹介ページのURL, 
"collectionViewUrl":アルバムのURL, 
"trackViewUrl":アルバムのURL, 
"previewUrl":試聴用ファイルのURL, 
"artworkUrl60":サムネイル(60x60)のURL, 
"artworkUrl100":サムネイル(100x100)のURL, 
"collectionPrice":価格(アルバム), 
"trackPrice":価格(1曲), 
"collectionExplicitness":ペアレンタルコントロール(explicit, cleaned, notExplicit),
"trackExplicitness":ペアレンタルコントロール(explicit, cleaned, notExplicit), 
"discCount":ディスク数, 
"discNumber":ディスク番号, 
"trackCount":トラック数, 
"trackNumber":トラック番号, 
"trackTimeMillis":曲の長さ(ミリ秒), 
"country":国, 
"currency":貨幣, 
"primaryGenreName":ジャンル

日本のitunesStoreからデータを受け取るのであれば、構造はほぼ変わらないはずなので、上記の内容を把握しておけば欲しいデータを取ることができます。
ちなみに、アメリカからデータを取得した場合とは若干内容が異なっていたので、国によって内容が異なる可能性があります。