拼接JSON数据 JSON标准格式 后台解析JSON

 //JSON标准格式
[
    {
        "state""success",
        "message""获取成功",
        "data": [
            {
                "id""ce2b2e0f-f3b8-46eb-b7fc-1088246951ea",
                "name""2015.7.8市级教研活动2",
                "starttime""2015/7/8 0:00:00",
                "endtime""2015/7/16 0:00:00"
            },
            {
                "id""f5c40800-ee64-4c9d-9653-928c1b67097f",
                "name""教研活动配置001",
                "starttime""2015/6/30 0:00:00",
                "endtime""2015/7/2 0:00:00"
            }
        ]
    }
]
View Code




                //根据记录表IDRecordID查找所有文件                
                

              IList<Model.FILECHANGE_FILE> listFile = cFile.GetList(" where t.RecordID", "");

              if (listFile.Count > 0)
                {
                    //返回JSON数据                    
                    

                    _strResult.Append("[");

 

                    foreach (var files in listFile)
                    {
                        _strResult.Append("{");
                        _strResult.Append("filename");
                        _strResult.Append("\"FILENAME\":\"" + files.FILENAME + "\",\"FILETYPE\":\"" + files.FILETYPE + "\",\"FILESIZE\":\"" + files.FILESIZE + "\",\"FILE\":\"" + "");
                        _strResult.Append("},");
                    }
                    if (listFile.Count > 0)
                    {
                        _strResult = _strResult.Remove(_strResult.ToString().LastIndexOf(','), 1);
                    }
                    _strResult.Append("]");
                }                   

 


dynamic listConvertcontent = JsonConvert.DeserializeObject(xmlElement.Attributes["convertcontent"].Value);

foreach (var item in listConvertcontent)
{
    Regex reg = new Regex(item["expression"].Value);
    HtmlNode childtemp2 = HtmlNode.CreateNode("<label>" + reg.Replace(sValue, item["replace"].Value) + "</label>");
    xmlElement.ChildNodes.Add(childtemp2);
}

posted @ 2015-05-05 16:34  Tz__C  阅读(734)  评论(0编辑  收藏  举报