2013-05-30 53 views
0

Ive得到这种JSON的由

{ 
    "media":{ 
     "1369725029":{ 
     "id_profil":"5738", 
     "photo_profil":"http:\/\/www.mupiz.com\/5738\/picture", 
     "phrase_feed":"a ajout\u00e9 une nouvelle chanson", 
     "nom_media":"La Douleur (chanson sur mon tableau)", 
     "nom_profil":"KRISS", 
     "url_profil":"kriss", 
     "streaming":"\r\n <div class=\"playerMedia\" onclick=\"InlinePlayer(this)\" data-url=\"http:\/\/www.mupiz.com\/mp3\/5738\/mp3_51550.mp3\" data-id=\"mp3_51550.mp3\">La Douleur (chanson sur mon tableau)<\/div>\r\n", 
     "url_media":"http:\/\/www.mupiz.com\/kriss\/la-douleur-chanson-sur-mon-tab" 
     }, 
     "1369723360":{ 
     "id_profil":"5738", 
     "photo_profil":"http:\/\/www.mupiz.com\/5738\/picture", 
     "phrase_feed":"a ajout\u00e9 une nouvelle chanson", 
     "nom_media":"On the Hi-Way (chanson)", 
     "nom_profil":"KRISS", 
     "url_profil":"kriss", 
     "streaming":"\r\n <div class=\"playerMedia\" onclick=\"InlinePlayer(this)\" data-url=\"http:\/\/www.mupiz.com\/mp3\/5738\/mp3_54344.mp3\" data-id=\"mp3_54344.mp3\">On the Hi-Way (chanson)<\/div>\r\n", 
     "url_media":"http:\/\/www.mupiz.com\/kriss\/on-the-hi-way-chanson1" 
     }, 
     "1368389617":{ 
     "id_profil":"32236", 
     "photo_profil":"http:\/\/www.mupiz.com\/32236\/picture", 
     "phrase_feed":"a ajout\u00e9 une nouvelle vid\u00e9o", 
     "nom_media":"P!nk - Just Give Me A Reason ft Nate Ruess (Real Chanty Cover) ", 
     "nom_profil":"Real Chanty", 
     "url_profil":"RealChanty", 
     "streaming":"<iframe width=\"270px\" height=\"200px\" src=\"http:\/\/www.youtube.com\/embed\/xiDzmc59fjg\" frameborder=\"0\" allowfullscreen><\/iframe>", 
     "url_media":"http:\/\/www.mupiz.com\/RealChanty\/video\/p-nk-just-give-me-a-reason-ft-nate-ruess-real-chanty-cover" 
     }, 
     "1368384065":{ 
     "id_profil":"1388", 
     "photo_profil":"http:\/\/www.mupiz.com\/1388\/picture", 
     "phrase_feed":"a ajout\u00e9 une nouvelle chanson", 
     "nom_media":"On the Hi-Way (chanson)", 
     "nom_profil":"Fred.Baz1-Compositeur-Bassiste-Guitariste", 
     "url_profil":"fred-bazin", 
     "streaming":"\r\n <div class=\"playerMedia\" onclick=\"InlinePlayer(this)\" data-url=\"http:\/\/www.mupiz.com\/mp3\/1388\/mp3_49786.mp3\" data-id=\"mp3_49786.mp3\">On the Hi-Way (chanson)<\/div>\r\n", 
     "url_media":"http:\/\/www.mupiz.com\/fred-bazin\/on-the-hi-way-chanson" 
     } 
    } 
} 

铬送得到“正确”为了FF没有,

任何想法?

+0

格式这所以不是所有的在一行 – aaronman

+0

解决,很容易任何想法,时间戳应该是为了通过递减。谢谢 – Anthony

回答

4

我不认为你可以依赖于JSON对象内属性的排序--JSON可以以任何顺序返回。

从JSON规范在http://www.json.org/

An object is an unordered set of name/value pairs 

可能重复? JSON order mixed up

+0

我如何使用$ .each保存此订单? – Anthony

+1

@ user1965147你不能用这个当前的设置做到这一点。这不能被转换为一个数组。我想你只能通过他们的名字来访问它:'json.media [“1369725029”]'(如果你想在你的json中选择第一个对象) – krishgopinath

1

不,因为JS没有维护订单,所以对于属性的定制没有必要。一般认为是因为这些是关键值对,顺序不需要保持。另一方面,对象数组可以并且将维持顺序,因为它被索引绑定并且可迭代。这是怎样一个对象数组的样子:正确

[ 
    { "name" : "test", "age" : 10 }, //index 0 
    { "name" : "test1" ,"age": 15 } //index 1 

] 
相关问题