微信小程序提交一下奇葩的json数据

小程序中提交一下奇葩的json格式如:

 const json={
      'File[0].FilePath':'0000000',
      'File[0].FileUploadName':'11111',
      'File[0].FileType':'2222',
      'File[1].FilePath':'3333',
      'File[1].FileUploadName':'444',
      'File[1].FileType':'5555',
 }

他这当中的key值是真的蛋疼,至少对于我这种新手来说是。我做了如下方法进行处理;自己记录一下,以免以后再遇到:

 const filearr = that.data.filepathlist
    let Files = []
    if(filearr.length!=0){
      filearr.forEach(function (item, idnex, array) {
       let files={
         'FilePath':item.path,
         'FileUploadName':(item.name).substring(0,49),
         'FileType':item.type
       }
       Files.push(files)
    })
    }

    let map = new Map();
    let jsons = {}
    Files.forEach((item, index) => {
      let a = `Files[${index}].FilePath`
      let b = `Files[${index}].FileUploadName`
      let c = `Files[${index}].FileType`
      map.set(a, item.FilePath)
      map.set(b, item.FileUploadName)
      map.set(c, item.FileType)
    })
    map.forEach((value, key) => {
      jsons[key] = value
    })
    jsons['StartDate'] = startDate
    jsons['EndDate'] = endDate
    jsons['UseDate'] = usedate
    jsons['HolidayType'] = holidaytype
    jsons['Reason'] = reason
    jsons['Memo'] = memo

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值