将list集合转换为Json字符串简单实现代码:
public static string GetJosn(List<CalendarInfo> list)
{ string jsonStr = "[";
if (list != null && list.Count > )
{
for (int i = ; i < list.Count; i++)
{
var entity = list[i];
if (i > )
{
jsonStr += ",";
}
//str += "['" + entity.Id + "','" + entity.Title.Replace("\\", @"\\").Replace("'", @"\'") + "',new Date(" + TimeHelper.MilliTimeStamp(entity.StartTime) + "),new Date(" + TimeHelper.MilliTimeStamp(entity.EndTime) + ")," + (entity.IsAllDayEvent ? "1" : "0") + "," + TimeHelper.CheckIsCrossEvent(entity) + "," + (2 == 2 ? "1" : "0") + "," + (string.IsNullOrEmpty(entity.Category) ? "-1" : entity.Category) + "]"; jsonStr +=
"['" + entity.Id + "','" + entity.Subject.Replace("\\", @"\\").Replace("'", @"\'")
+ "',new Date(" + TimeHelper.MilliTimeStamp(entity.StartTime) + "),new Date("
+ TimeHelper.MilliTimeStamp(entity.EndTime) + ")," + (entity.IsAllDayEvent ? "" : "")
+ "," + TimeHelper.CheckIsCrossEvent(entity) + "," + ( == ? "" : "") + ","
+ (string.IsNullOrEmpty(entity.Category) ? "-1" : entity.Category) + ",1,'"
+ "本公司" + "','" + "" + "" + (string.IsNullOrEmpty("") ? "" : ",") + "" + "' ]"; }
}
jsonStr += "]"; return jsonStr;
}