我正在使用Polymer 1.0進行項目工作,我想使用dom-repeat
來列出來自Firebase 3.0的數據。Javascript:將對象的對象轉換爲對象數組
在火力地堡我有這樣的對象的對象:
var objectofobjects = {
"-KR1cJhKzg9uPKAplLKd" : {
"author" : "John J",
"body" : "vfdvd",
"time" : "September 6th 2016, 8:11",
"title" : "vfvfd"
},
"-KR1cLZnewbvo45fDnEf" : {
"author" : "JJ",
"body" : "vfdvdvf",
"time" : "September 6th 2016, 8:11",
"title" : "vfvfdvfdv"
}
};
,我想將其轉換爲對象的數組,像這樣:
var arrayofobjects = [ { '-KR1cJhKzg9uPKAplLKd':
{ author: 'John J',
body: 'vfdvd',
time: 'September 6th 2016, 8:11',
title: 'vfvfd' },
'-KR1cLZnewbvo45fDnEf':
{ author: 'JJ',
body: 'vfdvdvf',
time: 'September 6th 2016, 8:11',
title: 'vfvfdvfdv' } } ];
這第二個結構是無效的JSON。 http://jsonlint.com/ –