组装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; }
 
                    
                     
                    
                 
                    
                 
 
         
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号