我recieving後續JSON轉化JS對象轉換成HTML
[
{
"fields": {
"url": "http://www.domain_name.co.uk/MP3/SF560783-01-01-01.mp3\n",
"track_name": "Lion City ",
"release_id": 560783,
"m3u_link": "http://www.domain_name.co.uk/playlists/builder/560783-01.m3u",
"track_number": 1
},
"model": "soundshelterapp.audiolinks",
"pk": 234422
},
{
"fields": {
"url": "http://www.domain_name.co.uk/MP3/SF560783-01-02-01.mp3\n",
"track_name": "Lion City (dub) ",
"release_id": 560783,
"m3u_link": "http://www.domain_name.co.uk/playlists/builder/560783-01.m3u",
"track_number": 2
},
"model": "soundshelterapp.audiolinks",
"pk": 234423
}
]
我想轉換成HTML這個如下: (href
來自fields['url']
和h3
來自fields['track_name']
<audio id="audio" preload="auto" tabindex="0" controls="" type="audio/mpeg">
<source type="audio/mp3" src="#">
</audio>
<ul id="playlist" style="display:none;">
<li class="active"><a href="http://www.domain_name.co.uk/MP3/SF560783-01-01-01.mp3"><h3>Lion City</h3></a></li>
<li class="active"><a href="http://www.domain_name.co.uk/MP3/SF560783-01-02-01.mp3"><h3>Lion City (dub)</h3></a></li>
</ul>
我知道我可以使用var newJ= $.parseJSON(data);
來閱讀JSON,但是我怎麼解析這個HTML格式?
這是不是一項簡單的任務。 StackOverflow用於詢問您正在編寫的代碼中遇到的問題。它不*請求人爲你寫代碼。 –
不尋找任何人編寫代碼,只是一個起點。 – Franco