• 微信小程序开发之拼接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"}]}

  • 相关阅读:
    洛谷#P5652#基础博弈练习题
    hgoi#20191112
    hgoi#20191111
    hgoi#20191109
    洛谷#P3674#小清新人渣的本愿
    hgoi#20191108
    hgoi#20191107
    树上差分
    树链剖分(树剖)
    LCA(最近公共祖先)问题
  • 原文地址:https://www.cnblogs.com/min-min-min/p/6978595.html
Copyright © 2020-2023  润新知