嵌套json到php搜索列表

时间:2011-12-11 07:48:05

标签: php html json parsing nested

我有一些json,我希望确定列出这个,当我做出选择时,我希望解析器过滤掉除了请求之外的所有其他内容,这里是我的代码,我会给出一个很好的解释我事后需要:

    <script type="text/javascript">
  $(document).ready(function() {
    var url="/json2php/posts.php";
    $.getJSON(url,function(data){
      $.each(data.posts,function(i,post) {
        var content,
        trackInfo = '',
        tracks = post.tracks;

        // loop over the tracks and collect info
        $.each(tracks, function (i) {
         trackInfo += '<li><a href="'+post.baseurl+''+ tracks[i].url +'"><font face="Arial">' + tracks[i].name + '</a></font></li><tr><td> ';
        });

        content = '<div class="post">'+
        '<table border="0"bgcolor="#F4F4F4"><tr><td><table border="0" bgcolor="#F5F5F5" width="500"><tr><td><center><font face="arial"><h1>'+post.album+'</h1>'+
        '<p><img src="'+post.artwork+'" height="250"></img></p>'+
        '<p><strong>'+post.church+'</strong></center></p>'+
        '<p><tr><td width="450"><font size="2" face="arial">Description: '+post.des+'</font></p>'+
        '</tr></td></table><td bgcolor="#EDEDED"><table border="0" width="300" height="100%" bgcolor="#EDEDED"><tr><td> <p><tr><td><ul><li><b>Tracks:</b><tr><td>  '+ trackInfo +'</li></p></ul></tr></td></table></tr></td></table><P>';
        '<hr>'+
        '</div>'

        $("#content").append(content);
      });
    });
  });
</script>

Json代码:

{"posts":[ {"id":"All Things Are Possible", "key":"All Things Are Possible", "doc":"All Things Are Possible", "album":"All Things Are Possible", "artwork":"http://godsgypsychristianchurch.net/music_artwork/DEFAULT_COVER.png", "baseurl":"http://www.godsgypsychristianchurch.net/music", "church":"Atlanta GA", "des":"All Things Are Possible from the Atlanta GA Church, Pastor Nick White", "tracks":[ {"name":"1 Intro", "url":"/Atlanta%20GA/All%20things%20are%20possible/01%20Intro.mp3"}, {"name":"2 Wo si O Drom", "url":"/Atlanta%20GA/All%20things%20are%20possible/02%20Wo%20si%20O%20drom.mp3"}, {"name":"3 Nas Murrgo Shov", "url":"/Atlanta%20GA/All%20things%20are%20possible/03%20Nas%20murrgo%20shov.mp3"}, {"name":"4 To Cho Vos", "url":"/Atlanta%20GA/All%20things%20are%20possible/04%20To%20cho%20vos.mp3"}, {"name":"5 Tu Son Kai Sastridas", "url":"/Atlanta%20GA/All%20things%20are%20possible/05%20Tu%20son%20kai%20sastridas.mp3"}, {"name":"6 Now I Am Strong", "url":"/Atlanta%20GA/All%20things%20are%20possible/06%20Now%20I%20am%20strong.mp3"}, {"name":"7 Sorr Nevee", "url":"/Atlanta%20GA/All%20things%20are%20possible/07%20Zorr%20nevee.mp3"}, {"name":"8 Preaching", "url":"/Atlanta%20GA/All%20things%20are%20possible/08%20Preaching.mp3"}, {"name":"9 Arkadyan Amey", "url":"/Atlanta%20GA/All%20things%20are%20possible/09%20Arkadyan%20amey.mp3"}, {"name":"10 O Christo Ka Wudarr", "url":"/Atlanta%20GA/All%20things%20are%20possible/10%20O%20Christo%20ka%20wudarr.mp3"}, {"name":"11 Eloi, Eloi", "url":"/Atlanta%20GA/All%20things%20are%20possible/11%20Eloi%2C%20Eloi.mp3"}, {"name":"12 Amadow Dell", "url":"/Atlanta%20GA/All%20things%20are%20possible/12%20Amadow%20Dell.mp3"}, {"name":"13 Sastiar Amey Devla", "url":"/Atlanta%20GA/All%20things%20are%20possible/13%20Sastiar%20amey%20Devla.mp3"}, {"name":"14 Tu Skepeese", "url":"/Atlanta%20GA/All%20things%20are%20possible/14%20Tu%20skepeese.mp3"}, {"name":"15 Dov Ma Godgee", "url":"/Atlanta%20GA/All%20things%20are%20possible/15%20Dov%20ma%20godgee.mp3"}, {"name":"16 The Lord is my strength", "url":"/Atlanta%20GA/All%20things%20are%20possible/16%20The%20Lors%20is%20my%20strength.mp3"}] }, {"id":"Can You See Him", "key":"Can You See Him", "doc":"Can You See Him", "album":"Can You See Him", "artwork":"http://godsgypsychristianchurch.net/music_artwork/DEFAULT_COVER.png", "baseurl":"http://www.godsgypsychristianchurch.net/music", "church":"Atlanta GA", "des":"Can You See Him from the Atlanta GA Church, Pastor Nick White", "tracks":[ {"name":"1 Aven Luvudes Les", "url":"/Atlanta%20GA/Can%20You%20See%20Him/01AvenLuvudesLes.mp3"}, {"name":"2 Aven Onglay", "url":"/Atlanta%20GA/Can%20You%20See%20Him/02AvenOnglay.mp3"}, {"name":"3 Chey Bistrov", "url":"/Atlanta%20GA/Can%20You%20See%20Him/03CheyBistrov.mp3"}, {"name":"4 Pred Ahmen", "url":"/Atlanta%20GA/Can%20You%20See%20Him/04PerdAhmen.mp3"}, {"name":"5 Swento Jeelabas", "url":"/Atlanta%20GA/Can%20You%20See%20Him/05SwentoJeelabas.mp3"}, {"name":"6 Pye O Shoovendow", "url":"/Atlanta%20GA/Can%20You%20See%20Him/06PyeOShoovendo.mp3"}, {"name":"7 Message", "url":"/Atlanta%20GA/Can%20You%20See%20Him/07Message.mp3"}, {"name":"8 Ryah Devla", "url":"/Atlanta%20GA/Can%20You%20See%20Him/08RyahDevla.mp3"}, {"name":"9 Hida Bowpahlay", "url":"/Atlanta%20GA/Can%20You%20See%20Him/09HidaBowpahlay.mp3"}, {"name":"10 Jeelaben Halleyjah", "url":"/Atlanta%20GA/Can%20You%20See%20Him/10JeelabenHalleujah.mp3"}, {"name":"11 Chey Bahro San Devla", "url":"/Atlanta%20GA/Can%20You%20See%20Him/11CheyBahroSanDevla.mp3"}, {"name":"12 Woe Sa Kahtey", "url":"/Atlanta%20GA/Can%20You%20See%20Him/12WoeSaKahtey.mp3"}, {"name":"13 Noomah Pacha", "url":"/Atlanta%20GA/Can%20You%20See%20Him/13NoomahPahcha.mp3"}, {"name":"14 To Worship You I Live", "url":"/Atlanta%20GA/Can%20You%20See%20Him/14ToWorshipYouILive.mp3"}, {"name":"15 Regev Mon Devla", "url":"/Atlanta%20GA/Can%20You%20See%20Him/15RegevMonDevla.mp3"} ]}, {"id":"Dey Duma Amensa", "key":"Dey Duma Amensa", "doc":"Dey Duma Amensa", "album":"Dey Duma Amensa", "artwork":"http://godsgypsychristianchurch.net/music_artwork/DEFAULT_COVER.png", "baseurl":"http://www.godsgypsychristianchurch.net/music", "church":"Atlanta GA", "des":"Dey Duma Amensa from the Atlanta GA Church, Pastor Nick White", "tracks":[ {"name":"1 Greeting", "url":"/Atlanta%20GA/Dey%20duma%20amensa/01%20Greeting.mp3"}, {"name":"2 Godya Vramya", "url":"/Atlanta%20GA/Dey%20duma%20amensa/02%20Godya%20vramya.mp3"}, {"name":"3 Vosdoa Vos, Geelabos", "url":"/Atlanta%20GA/Dey%20duma%20amensa/03%20Vosdoa%20vos%2C%20geelabos.mp3"}, {"name":"4 Amey Luvudees Tu", "url":"/Atlanta%20GA/Dey%20duma%20amensa/04%20Amey%20lubudees%20tu.mp3"}, {"name":"5 Dey Duma Amensa", "url":"/Atlanta%20GA/Dey%20duma%20amensa/05%20Dey%20duma%20amensa.mp3"}, {"name":"6 Preaching", "url":"/Atlanta%20GA/Dey%20duma%20amensa/06%20Preaching.mp3"}, {"name":"7 I Came to Worship you", "url":"/Atlanta%20GA/Dey%20duma%20amensa/07%20I%20came%20to%20worship%20you.mp3"}, {"name":"8 Kon Komel", "url":"/Atlanta%20GA/Dey%20duma%20amensa/08%20Kon%20Komel.mp3"}, {"name":"9 Hydee Swento Ducho", "url":"/Atlanta%20GA/Dey%20duma%20amensa/09%20Hydee%20Swento%20Ducho.mp3"}, {"name":"10 Mey Luvudeev Tu", "url":"/Atlanta%20GA/Dey%20duma%20amensa/10%20Mey%20luvudeev%20tu.mp3"}, {"name":"11 Dov Murrgo Tryo", "url":"/Atlanta%20GA/Dey%20duma%20amensa/11%20Dov%20murrgo%20tryo.mp3"}, {"name":"12 Amey Luvudees tu", "url":"/Atlanta%20GA/Dey%20duma%20amensa/12%20Amey%20luvudees%20tu.mp3"}, {"name":"13 Adjes", "url":"/Atlanta%20GA/Dey%20duma%20amensa/13%20Adjes.mp3"}, {"name":"14 Wusteelow", "url":"/Atlanta%20GA/Dey%20duma%20amensa/14%20Wusteelow.mp3"}] }, {"id":"Tuka Jeelabas", "key":"Tuka Jeelabas", "doc":"Tuka Jeelabas", "album":"Tuka Jeelabas", "artwork":"http://godsgypsychristianchurch.net/music_artwork/DEFAULT_COVER.png", "baseurl":"http://www.godsgypsychristianchurch.net/music", "church":"Atlantic City", "des":"Tuka Jeelabas From the Atlantic City Church, Pastor Sam", "tracks":[ {"name":"1 Tuka Jeelabas", "url":"/Atlantic%20City/Tuka%20Jeelabas/01%20Tuka%20Jeelabas.mp3"}, {"name":"2 Odel Trodass", "url":"/Atlantic%20City/Tuka%20Jeelabas/02%20Odel%20Trodass.mp3"}, {"name":"3 May Sudov", "url":"/Atlantic%20City/Tuka%20Jeelabas/03%20May%20Sudov.mp3"}, {"name":"4 Moo Si Yetees", "url":"/Atlantic%20City/Tuka%20Jeelabas/04%20Moo%20Si%20Yetees.mp3"}, {"name":"5 Ferrdey Cho Annov", "url":"/Atlantic%20City/Tuka%20Jeelabas/05%20Ferrdey%20Cho%20Annov.mp3"}, {"name":"6 Aven Jeelabas", "url":"/Atlantic%20City/Tuka%20Jeelabas/06%20Aven%20Jeelabas.mp3"}, {"name":"7 Penas Hallelujah", "url":"/Atlantic%20City/Tuka%20Jeelabas/07%20Penas%20Hallelujah.mp3"}, {"name":"8 Falling in Love with Jesus", "url":"/Atlantic%20City/Tuka%20Jeelabas/08%20Falling%20in%20Love%20with%20Jesus.mp3"}, {"name":"9 Lord You Are", "url":"/Atlantic%20City/Tuka%20Jeelabas/09%20Lord%20You%20Are.mp3"}, {"name":"10 Tu Des Pocha", "url":"/Atlantic%20City/Tuka%20Jeelabas/10%20Tu%20Des%20Pocha.mp3"}, {"name":"11 Numma Odel", "url":"/Atlantic%20City/Tuka%20Jeelabas/11%20Numma%20Odel.mp3"}, {"name":"12 Preaching", "url":"/Atlantic%20City/Tuka%20Jeelabas/12%20Preaching.mp3"}] }, {"id":"Set Free", "key":"Set Free", "doc":"Set Free", "album":"Set Free", "artwork":"http://godsgypsychristianchurch.net/music_artwork/maryland/maryland.jpg", "baseurl":"http://www.godsgypsychristianchurch.net/music", "church":"Baltimore MD", "des":"This album is from the Baltimore MD Church, Pastor Nicky", "tracks":[ {"name":"1 Set Free", "url":"/Maryland/Set_Free/01%20SET%20FREE.mp3"}, {"name":"2 Chedo Anov", "url":"/Maryland/Set_Free/02%20CHEDO%20ANOV.mp3"}, {"name":"3 Ajujaras", "url":"/Maryland/Set_Free/03%20AJUKARAS.mp3"}, {"name":"4 Pey cho drom", "url":"/Maryland/Set_Free/04%20PEY%20CHO%20DROM.mp3"}, {"name":"5 Rie la Rieango", "url":"/Maryland/Set_Free/05%20RIE%20LA%20RIEANGO.mp3"}, {"name":"6 Asoonen", "url":"/Maryland/Set_Free/06%20ASOONEN.mp3"}, {"name":"7 Aven", "url":"/Maryland/Set_Free/07%20AVEN.mp3"}, {"name":"8 Falling in love with Jesus", "url":"/Maryland/Set_Free/08%20FALLING%20IN%20LOVE%20WITH%20JESUS.mp3"}, {"name":"9 Hallelujah", "url":"/Maryland/Set_Free/09%20HALLELUJAH.mp3"}, {"name":"10 Kie woodod", "url":"/Maryland/Set_Free/10%20KIE%20WOODOD.mp3"}, {"name":"11 Jesus Messiah", "url":"/Maryland/Set_Free/11%20JESUS%20MESSIAH.mp3"}, {"name":"12 Tu Son Swento", "url":"/Set_Free/12%20TU%20SON%20SWINTO.mp3"}, {"name":"13 Mey lulvodeev", "url":"/Maryland/Set_Free/13%20MEY%20LUVOODEV.mp3"}, {"name":"14 Preaching", "url":"/Maryland/Set_Free/14%20PREACHING.mp3"}] }, {"id":"Belgim", "key":"Belgim", "doc":"Belgim", "album":"Belgim", "artwork":"http://godsgypsychristianchurch.net/music_artwork/DEFAULT_COVER.png", "baseurl":"http://www.godsgypsychristianchurch.net/music", "church":"Belgim", "des":"This Album is from Belgim", "tracks":[ {"name":"1 Wo radeweel", "url":"/Belgim/Belgim/01%20Wo%20radeweel.mp3"}, {"name":"2 Sarr Cho Shov", "url":"/Belgim/Belgim/02%20Sarr%20cho%20shov.mp3"}, {"name":"3 O Del Juveendo", "url":"/Belgim/Belgim/03%20O%20Del%20juveendo.mp3"}, {"name":"4 Che Pagudelan", "url":"/Belgim/Belgim/04%20Che%20pagudelan.mp3"}, {"name":"5 Tu Christo", "url":"/Belgim/Belgim/05%20Tu%20Christo.mp3"}, {"name":"6 Hyda Palpaley", "url":"/Belgim/Belgim/06%20Hyda%20palpaley.mp3"}, {"name":"7 Amadow Del Pendos", "url":"/Belgim/Belgim/07%20Amadow%20Del%20pendos.mp3"}] }, {"id":"Victory Over The Enemy", "key":"Victory Over The Enemy", "doc":"Victory Over The Enemy", "album":"Victory Over The Enemy", "artwork":"http://godsgypsychristianchurch.net/music_artwork/boston/screen-capture-15.jpg", "baseurl":"http://www.godsgypsychristianchurch.net/music", "church":"Boston MA", "des":"Victory Over The Enemy from the Boston MA Church, Pastor Tony", "tracks":[ {"name":"1 Got the Victory", "url":"/Boston/Victory%20Over%20The%20Enemy/01%201%20Got%20the%20victory.mp3"}, {"name":"2 Your all i want", "url":"/Boston/Victory%20Over%20The%20Enemy/02%202%20Your%20all%20i%20want.mp3"}, {"name":"3 Chee Yog", "url":"/Boston/Victory%20Over%20The%20Enemy/03%203%20Chee%20yog.mp3"}, {"name":"4 This is what the lord says", "url":"/Boston/Victory%20Over%20The%20Enemy/04%204%20This%20is%20what%20the%20lord%20says.mp3"}, {"name":"5 Vasdas Choanav", "url":"/Boston/Victory%20Over%20The%20Enemy/05%205%20Vasdas%20Choanav.mp3"}, {"name":"6 Woigese Amene", "url":"/Boston/Victory%20Over%20The%20Enemy/06%206%20Woigese%20Amene.mp3"}, {"name":"7 I Win", "url":"/Boston/Victory%20Over%20The%20Enemy/07%207%20I%20win.mp3"}, {"name":"8 Surrender All", "url":"/Boston/Victory%20Over%20The%20Enemy/08%208%20Surrender%20All.mp3"}, {"name":"9 Chee mi Makov", "url":"/Boston/Victory%20Over%20The%20Enemy/09%209%20Chee%20mi%20makov.mp3"}, {"name":"10 Konna del asbal", "url":"/Boston/Victory%20Over%20The%20Enemy/10%2010%20Konna%20del%20asbal.mp3"}, {"name":"11 Agese", "url":"/Boston/Victory%20Over%20The%20Enemy/11%2011%20Agese.mp3"}, {"name":"12 Swentow", "url":"/Boston/Victory%20Over%20The%20Enemy/12%2012%20Swinto.mp3"}, {"name":"13 Preaching", "url":"/Boston/Victory%20Over%20The%20Enemy/13%2013%20Preaching.mp3"}, {"name":"14 ive been redeemed", "url":"/Boston/Victory%20Over%20The%20Enemy/14%2014%20Ive%20been%20redeemed.mp3"}] }, {"id":"Blessed be the Lord", "key":"Blessed be the Lord", "doc":"Blessed be the Lord", "album":"Blessed be the Lord", "artwork":"http://godsgypsychristianchurch.net/music_artwork/DEFAULT_COVER.png", "baseurl":"http://www.godsgypsychristianchurch.net/music", "church":"Brooklyn/Queens NY", "des":"This album is from the Brookly Brooklyn/Queens NY Church, Pastor Lavay", "tracks":[ {"name":"Track 1", "url":"/Brooklyn%20NY/Blessed%20be%20the%20Lord/01%20AudioTrack%2001.mp3"}, {"name":"Track 2", "url":"/Brooklyn%20NY/Blessed%20be%20the%20Lord/02%20AudioTrack%2002.mp3"}, {"name":"Track 3", "url":"/Brooklyn%20NY/Blessed%20be%20the%20Lord/03%20AudioTrack%2003.mp3"}, {"name":"Track 4", "url":"/Brooklyn%20NY/Blessed%20be%20the%20Lord/04%20AudioTrack%2004.mp3"}, {"name":"Track 5", "url":"/Brooklyn%20NY/Blessed%20be%20the%20Lord/05%20AudioTrack%2005.mp3"}, {"name":"Track 6", "url":"/Brooklyn%20NY/Blessed%20be%20the%20Lord/06%20AudioTrack%2006.mp3"}, {"name":"Track 7", "url":"/Brooklyn%20NY/Blessed%20be%20the%20Lord/07%20AudioTrack%2007.mp3"}, {"name":"Track 8", "url":"/Brooklyn%20NY/Blessed%20be%20the%20Lord/08%20AudioTrack%2008.mp3"}, {"name":"Track 9", "url":"/Brooklyn%20NY/Blessed%20be%20the%20Lord/09%20AudioTrack%2009.mp3"}, {"name":"Track 10", "url":"/Brooklyn%20NY/Blessed%20be%20the%20Lord/10%20AudioTrack%2010.mp3"}, {"name":"Track 11", "url":"/Brooklyn%20NY/Blessed%20be%20the%20Lord/11%20AudioTrack%2011.mp3"}, {"name":"Track 12", "url":"/Brooklyn%20NY/Blessed%20be%20the%20Lord/12%20AudioTrack%2012.mp3"}, {"name":"Track 13", "url":"/Brooklyn%20NY/Blessed%20be%20the%20Lord/13%20AudioTrack%2013.mp3"}] }, {"id":"Bring back the new again", "key":"Bring back the new again", "doc":"Bring back the new again", "album":"Bring back the new again", "artwork":"http://godsgypsychristianchurch.net/music_artwork/DEFAULT_COVER.png", "baseurl":"http://www.godsgypsychristianchurch.net/music", "church":"Brooklyn/Queens NY", "des":"This album is from the Brooklyn/Queens NY Church, Pastor Lavay", "tracks":[ {"name":"1 Opening Prayer", "url":"/Brooklyn%20NY/Bring%20back%20the%20new%20again/01%20Opening%20prayer.mp3"}, {"name":"2 Bring back the new again", "url":"/Brooklyn%20NY/Bring%20back%20the%20new%20again/02%20Bring%20back%20the%20new.mp3"}, {"name":"3 Luvudesarrav", "url":"/Brooklyn%20NY/Bring%20back%20the%20new%20again/03%20Luvudesarrav.mp3"}, {"name":"4 My Peace", "url":"/Brooklyn%20NY/Bring%20back%20the%20new%20again/04%20My%20peace.mp3"}, {"name":"5 Jovas Jovas", "url":"/Brooklyn%20NY/Bring%20back%20the%20new%20again/05%20Jovas%20Jovas.mp3"}, {"name":"6 Halleluja", "url":"/Brooklyn%20NY/Bring%20back%20the%20new%20again/06%20Halleluja.mp3"}, {"name":"7 Badow Trusul", "url":"/Brooklyn%20NY/Bring%20back%20the%20new%20again/07%20Badow%20trusul.mp3"}, {"name":"8 Sarr Davine", "url":"/Brooklyn%20NY/Bring%20back%20the%20new%20again/08%20Sarr%20David.mp3"}, {"name":"10 Amey Somas", "url":"/Brooklyn%20NY/Bring%20back%20the%20new%20again/10%20Amey%20somas.mp3"}, {"name":"11 Aven ka Yezues", "url":"/Brooklyn%20NY/Bring%20back%20the%20new%20again/11%20Aven%20ka%20Jesus.mp3"}, {"name":"12 Aven Che Shovey", "url":"/Brooklyn%20NY/Bring%20back%20the%20new%20again/12%20Aven%20che%20shovey.mp3"}, {"name":"13 Ducho le Devlesko", "url":"/Brooklyn%20NY/Bring%20back%20the%20new%20again/13%20Ducho%20le%20Devlesko.mp3"}, {"name":"14 Aven Rromaley", "url":"/Brooklyn%20NY/Bring%20back%20the%20new%20again/14%20Aven%20Rromaley.mp3"}, {"name":"15 Instrumental", "url":"/Brooklyn%20NY/Bring%20back%20the%20new%20again/15%20Instrumental.mp3"}, {"name":"16 Hyden Monsa", "url":"/Brooklyn%20NY/Bring%20back%20the%20new%20again/16%20Hyden%20monsa.mp3"}, {"name":"17 Aven Savogon", "url":"/Brooklyn%20NY/Bring%20back%20the%20new%20again/17%20Aven%20savogon.mp3"}, {"name":"18 Closing Prayer", "url":"/Brooklyn%20NY/Bring%20back%20the%20new%20again/18%20Closing%20prayer.mp3"}] }, {"id":"Brooklyn First Studio Tape", "key":"Brooklyn First Studio Tape", "doc":"Brooklyn First Studio Tape", "album":"Brooklyn First Studio Tape", 

我希望post.church成为第一个可见的东西(基本上是一个教堂名单列表),但请记住,在json中多次提到一些教堂,所以我只需要它们在最终的html中列出它们的onces输出(例如:教堂1,教堂2,教堂3等)

假设用户点击“教堂2”。我希望列出该教堂的专辑,然后点击“专辑3”,可以看到艺术作品,描述和曲目。

现在我在一个页面上显示所有内容,如何过滤它(请使用完整代码)

http://www.ggcc.tv/json2php查看我到目前为止的内容(随意查看源代码) 你可以看看我在这里使用的json http://www.ggcc.tv/json2php/posts.php

简单地说

此订单中的可点击链接列表 “教会名称”(点击时会带你到a)“专辑列表”(来自该教堂,点击时带你到)“专辑插图,描述和链接”

教会名称&gt;专辑列表&gt;专辑曲目 (基本上是过滤器) 在此先感谢您的帮助

0 个答案:

没有答案