直接上代码 :
var imageitem;
var imageitemstring=‘‘;
for(var i=0;i< that.data.fbimages.length;i++)
{
imageitem=‘{"fileUrl":"‘+ that.data.fbimages[i] +‘"}‘;
if(i<that.data.fbimages.length-1)
{imageitemstring += imageitem + ‘,‘;}
else{imageitemstring += imageitem}
}
var imageList=‘{"imageList":[‘+imageitemstring+‘]}‘;
fbimages为fileURL文件路径的数组;最终格式化的数据为:
{"imageList":[{"fileUrl":"http://218.87.254.137:7999/uploads/20170528/48e11aa9-88ef-449e-b617-513c83a09f40.jpg"},{"fileUrl":"http://218.87.254.137:7999/uploads/20170528/4050ceaa-1673-42e8-97ea-56991290ad76.png"},{"fileUrl":"http://218.87.254.137:7999/uploads/20170528/59403872-0f18-43a6-93e4-53a0816bd047.jpg"}]}
时间: 2024-12-14 11:45:29