zoukankan      html  css  js  c++  java
  • 处理json的常用方式

    1:将json中列表对象。循环添加到数据库

    List<dynamic> FileList = jss.Deserialize<List<dynamic>>(c.Request["FileList"]); 
    if (FileList != null && FileList.Count > 0)
    { FileList.ForEach(x => { Model.Work.wfFiles fiel = new Model.Work.wfFiles();
    fiel.FileName = x["FileName"]; fiel.FilePath = x["FilePath"];
    fiel.Extend = x["Extend"];
    fiel.FileType = Convert.ToInt32(x["FileType"]);
    fiel.BelongTable = "pmCompanyChange";
    fiel.BelongId = cid;
    fiel.State = (int)StateEnum.State.Enable;
    fiel.RoleId = Convert.ToInt32(CommonInfo.UserSysId(account.Id));
    fiel.CompanyId = Convert.ToInt32(CommonInfo.pmCompanyId(account.Id));
    fiel.CreateBy = account.AccountName; fiel.CreateById = account.Id;
    fiel.CreateDate = DateTime.Now;
    fiel.Id = IBLL.Factory.wfFilesCreate().Add(fiel);
    fid = fiel.Id + ",";
    });
    }

      

    2、遍历JSON数组代码如下:

    var packJson = [{"name":"Liza", "password":"123"}, {"name":"Mike", "password":"456"}];
    for(var i in packJson){//遍历packJson 数组时,i为索引
    alert(packJson[i].name + " " + packJson[i].password);
    }
  • 相关阅读:
    极验验证(滑动验证)的使用
    from close /destory
    tmeminifile and tinifile
    Delphi的OverRide、OverLoad和Virtual方法
    XE6 FMX之控件绘制与显示
    Delphi Android程序启动过程
    Delphi中的容器类
    接口
    集合
    class methed
  • 原文地址:https://www.cnblogs.com/shanshuiYiCheng/p/11720438.html
Copyright © 2011-2022 走看看