var jsonObj=[]; 
var tempPrdList=[];

tempPrdList.push("12");
tempPrdList.push("34");
tempPrdList.push("56");

for (i = 0, j = tempPrdList.length; i < j; i++) {
  var obj = new Object;
  obj.id = tempPrdList[i];  //key=id
  jsonObj.push(obj);
}

console.log(JSON.stringify(jsonObj));  //[{"id":"12"},{"id":"34"},{"id":"56"}]
arrow
arrow
    文章標籤
    javascript json array
    全站熱搜

    咪卡恰比 發表在 痞客邦 留言(0) 人氣()