欢迎来到天天文库
浏览记录
ID:56825596
大小:36.50 KB
页数:5页
时间:2020-07-15
《C#生成Json格式文档.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、随笔-14文章-0评论-5C#生成JSON数据格式的函数使用说明:对List<类>集合使用的方法:ListobjList=objAction.GetCODE_MByList(objTbl);stringJsonSource=JSONHelper.ToJSON(objList);//当前页记录转成JSON格式但有个问题:日期型数据谁转换成:@@这样的数据!???不知道谁碰到过没有!!!!对数据集的使用如:DataSet,DataTableJSONHelperjsonHelp=newJSONHelper();jsonHel
2、p.success=true;jsonHelp.totlalCount=getPrjListCount();foreach(DataRowdrindsResult.Tables[0].Rows)...{jsonHelp.AddItem("PRJ_ID",dr["PRJ_ID"].ToString());jsonHelp.AddItem("PRJ_NAME",dr["PRJ_NAME"].ToString());jsonHelp.AddItem("DEP_ID",dr["DEP_ID"].ToString());jsonHelp.AddItem(
3、"PRJ_MANID",dr["PRJ_MANID"].ToString());jsonHelp.AddItem("PRJ_STATE",dr["PRJ_STATE"].ToString());if(dr["PRJ_STARTDATE"]!=DBNull.Value)...{jsonHelp.AddItem("PRJ_STARTDATE",Convert.ToDateTime(dr["PRJ_STARTDATE"]).ToString("yyyy/MM/dd"));}else...{jsonHelp.AddItem("PRJ_STARTDATE
4、",string.Empty);}if(dr["PRJ_ENDDATE"]!=DBNull.Value)...{jsonHelp.AddItem("PRJ_ENDDATE",Convert.ToDateTime(dr["PRJ_ENDDATE"]).ToString("yyyy/MM/dd"));}else...{jsonHelp.AddItem("PRJ_ENDDATE",string.Empty);}jsonHelp.AddItem("PRJ_MEMO",dr["PRJ_MEMO"].ToString());jsonHelp.AddItem
5、("CODE_NAME",dr["CODE_NAME"].ToString());jsonHelp.AddItem("DEP_NAME",dr["DEP_NAME"].ToString());jsonHelp.AddItem("USER_NAME",dr["USER_NAME"].ToString());jsonHelp.ItemOk();}stringstrResult=jsonHelp.ToString();//######################JSONHelp.cs源码##############################
6、########//usingSystem;usingSystem.Collections;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Web.Script.Serialization;namespaceframework.common...{/**///////JSONHelper的摘要说明///publicclassJSONHelper...{//对应JSON的singleInfo成员publicstringsingleInf
7、o=string.Empty;protectedstring_error=string.Empty;protectedbool_success=true;protectedlong_totalCount=0;protectedSystem.Collections.ArrayListarrData=newArrayList();publicJSONHelper()...{}publicstaticstringToJSON(objectobj)...{JavaScriptSerializerserializer=newJavaScriptSeria
8、lizer();returnserializer.Serialize(obj);}publicstaticstringToJSON(objectobj
此文档下载收益归作者所有