macT

组装json对象

public string strTree(DataTable dt, string type, string state)
        {
            string strjosn = "";
            foreach (DataRow dr in dt.Rows)
            {
                if (string.IsNullOrEmpty(strjosn))
                {
                    strjosn = "{\"id\":\"" + dr[1] + "\",\"text\":\"" + dr[0] + "\",\"state\":\"" + state +
                              "\",\"attributes\":{\"type\":\"" + type + "\"}}";
                }
                else
                {
                    strjosn += "," + "{\"id\":\"" + dr[1] + "\",\"text\":\"" + dr[0] + "\",\"state\":\"" + state +
                               "\",\"attributes\":{\"type\":\"" + type + "\"}}";
                }
            }
            strjosn = "[" + strjosn + "]";
            return strjosn;
        }

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-05-05
  • 2021-11-28
  • 2021-12-17
  • 2021-07-17
  • 2022-01-28
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2022-12-23
  • 2022-12-23
  • 2021-10-31
  • 2022-12-23
相关资源
相似解决方案