找到一個方法,雖然返回的不是json,可是數據格式是能夠的json
ArrayList eventList = new ArrayList(); for (int i = 0; i < 3;i++ ) { Hashtable ht = new Hashtable(); ht.Add("eventid",i+1); ht.Add("eventname","聖誕節"); ht.Add("eventdate","2012-12-25"); ht.Add("eventlocation","公司會議中心"); eventList.Add(ht); } JavaScriptSerializer ser = new JavaScriptSerializer(); String jsonStr=ser.Serialize(eventList); Response.Write(jsonStr);