public class Product
{
public string Name { get; set; }
public double Price { get; set; }
public override string ToString()
{
return "Name: " + Name + ", Price: " + Price;
}
}
Product product = new Product();
product.Name = "青椒";
product.Price = 1.5;
string serializerJson = JsonConvert.SerializeObject(product);
Product pro = (Product) JsonConvert.DeserializeObject<Product>(serializerJson);
// Product pro = (Product)JsonConvert.DeserializeObject(serializerJson, typeof (Product)); // 重载方法