首页 > Web开发 > 详细

SPListItem拼接成Json格式

时间:2014-07-14 21:10:11      阅读:509      评论:0      收藏:0      [点我收藏+]
可以试着将SPList.Items转化成Json格式。
 
public static string GetJsonFormSplistItem(SPListItem item, string[] strArr)
        {
            string json = "{";
            for (int i = 0; i < item.ParentList.Fields.Count - 1; i++)
            {
                string fieldName = item.ParentList.Fields[i].InternalName;
                ArrayList ar = new ArrayList();//实例化一个ArrayList
                ar.AddRange(strArr);//把数组赋到Arraylist对象
                if (ar.Contains(fieldName))
                {
                    if (item[i] != null)
                    {
                        json += "\"" + fieldName + "\":\"" + item[i].ToString() + "\",";
                    }
                    else
                    {
                        json += "\"" + fieldName + "\":\"\",";
                    }
 
                }
            }
            json += "},";
            return json;
        }
 
public string[] problemRiskArr = { "ProjectName", "ProblemBody", "AffectDegree", "User", "CountermoveBody", "Status" };

SPListItem拼接成Json格式,布布扣,bubuko.com

SPListItem拼接成Json格式

原文:http://www.cnblogs.com/yixiaozi/p/3842715.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!