zoukankan      html  css  js  c++  java
  • 微信小程序开发之拼接json数组字符串

    直接上代码   :

    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"}]}

  • 相关阅读:
    2018第0次作业
    第八次作业
    第七次作业
    第六次作业
    第四次作业
    第三次作业
    第二次作业
    第3次作业
    第2次作业
    第1次作业
  • 原文地址:https://www.cnblogs.com/min-min-min/p/6978595.html
Copyright © 2011-2022 走看看