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"}]
文章標籤
全站熱搜