json学习笔记(6)
return result;
}
}
person类的修改:
View Code
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
public DateTime LastLoginTime { get; set; }
}
实例调用及对集合、字典、数组的处理:
View Code
protected void Page_Load(object sender, EventArgs e)
{
Person ps = new Person();
ps.Age = 22;
ps.Name = "Ace";
ps.LastLoginTime = DateTime.Now;
            string json = JsonHelper.JsonSerializer<Person>(ps);
            Response.Write(json);
            List<Person> lt = new List<Person>()
            {
            new Person(){Name="Ace",Age=22,LastLoginTime=DateTime.Now},
            new Person(){Name="Getes",Age=55,LastLoginTime=DateTime.Now}
            };
            string jsonstring = JsonHelper.JsonSerializer<List<Person>>(lt);
            Response.Write(jsonstring);
            Dictionary<string, string> dy = new Dictionary<string, string>();
            dy.Add("Name", "Ace");
            dy.Add("Age","22");
            string json1 = JsonHelper.JsonSerializer<Dictionary<string, string>>(dy);
            Response.Write(json1);
        }
用javascript处理
  View Code
//        在后台替换字符串适用范围比较窄,如果考虑到全球化的有多种语言还会更麻烦。
    //2. 利用JavaScript处理
	
相关新闻>>
- 发表评论
- 
				
- 最新评论 进入详细评论页>>



