将SPList.Items转化成Json格式。
1 public static string GetJsonFormSplistItem(SPListItem item, string[] strArr) 2 { 3 string json = "{"; 4 for (int i = 0; i < item.ParentList.Fields.Count - 1; i++) 5 { 6 string fieldName = item.ParentList.Fields[i].InternalName; 7 ArrayList ar = new ArrayList();//实例化一个ArrayList 8 ar.AddRange(strArr);//把数组赋到Arraylist对象 9 if (ar.Contains(fieldName)) 10 { 11 if (item[i] != null) 12 { 13 json += """ + fieldName + "":"" + item[i].ToString() + "","; 14 } 15 else 16 { 17 json += """ + fieldName + "":"","; 18 } 19 20 } 21 } 22 json += "},"; 23 return json; 24 } 25 26 public string[] problemRiskArr = { "ProjectName", "ProblemBody", "AffectDegree", "User", "CountermoveBody", "Status" };