小编jon*_*985的帖子

解码json并迭代django模板中的项目

嗨,我使用simplejson导入一些json然后解码以在django模板中使用,

这是解码的json:

{u'ServerID': 1, u'Cache': {u'CacheBusted': False, u'FromCache': True}, u'Result': [{u'Url': u'http://listen.grooveshark.com/playlist/Soul_Power/399134', u'Cache': {u'FromCache': True}, u'PlaylistID': u'399134', u'Name': u'Soul Power', u'ModifiedTime': u'1229427645'}, {u'Url': u'http://listen.grooveshark.com/playlist/4RK_(v.3)/491934', u'Cache': {u'FromCache': True}, u'PlaylistID': u'491934', u'Name': u'4RK (v.3)', u'ModifiedTime': u'1231028348'}, {u'Url': u'http://listen.grooveshark.com/playlist/My_Bands/3735842', u'Cache': {u'FromCache': True}, u'PlaylistID': u'3735842', u'Name': u'My Bands', u'ModifiedTime': u'1234384383'}, {u'Url': u'http://listen.grooveshark.com/playlist/Go_Move_Cruise/19255842', u'Cache': {u'FromCache': True}, u'PlaylistID': u'19255842', u'Name': u'Go Move Cruise', u'ModifiedTime': u'1259081222'}, {u'Url': u'http://listen.grooveshark.com/playlist/Goodnight/19854340', u'Cache': {u'FromCache': True}, u'PlaylistID': u'19854340', u'Name': u'Goodnight', u'ModifiedTime': u'1259457504'}, {u'Url': u"http://listen.grooveshark.com/playlist/Bottle_Poppin'_with_Friends_&_Scarfs/22398199", u'Cache': {u'FromCache': True}, u'PlaylistID': u'22398199', u'Name': u"Bottle Poppin' …
Run Code Online (Sandbox Code Playgroud)

python django json loops simplejson

8
推荐指数
1
解决办法
1万
查看次数

jquery循环通过json

嗨,我试图像这样循环一个json文件:

$.each(data.playlists.playlist, function(i, item) {

              $("#contentC").append('<p>' + item.id + '</p>'); 
              $("#contentC").append('<p>' + item.title + '</p>'); 
              $("#contentC").append('<p>' + item.url + '</p>'); }
           ); 
Run Code Online (Sandbox Code Playgroud)

JSON:

{
   "playlists":{
      "playlist":[
         {
            "id":"8391802",
            "title":"Second Playlist",
            "description":"",
            "date":"2011-03-06T18:53:33",
            "size":"10",
            "duration":"2267",
            "streamable":"0",
            "creator":"http:\/\/www.last.fm\/user\/jon21021985",
            "url":"http:\/\/www.last.fm\/user\/jon21021985\/library\/playlists\/4zv5m_second_playlist",
            "image":[
               {
                  "#text":"",
                  "size":"small"
               },
               {
                  "#text":"",
                  "size":"medium"
               },
               {
                  "#text":"",
                  "size":"large"
               },
               {
                  "#text":"",
                  "size":"extralarge"
               }
            ]
         },
         {
            "id":"8372409",
            "title":"All-american Rejects",
            "description":"",
            "date":"2011-02-28T13:30:01",
            "size":"6",
            "duration":"785",
            "streamable":"0",
            "creator":"http:\/\/www.last.fm\/user\/jon21021985",
            "url":"http:\/\/www.last.fm\/user\/jon21021985\/library\/playlists\/4zg6x_all-american_rejects",
            "image":[
               {
                  "#text":"",
                  "size":"small"
               },
               {
                  "#text":"",
                  "size":"medium"
               },
               {
                  "#text":"",
                  "size":"large"
               }, …
Run Code Online (Sandbox Code Playgroud)

jquery json

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

json ×2

django ×1

jquery ×1

loops ×1

python ×1

simplejson ×1