参考文章:http://www.cnblogs.com/youring2/archive/2012/05/28/2520922.html
添加引用:
使用NuGet,命令:install-package Newtonsoft.Json
实体类:
[csharp]
public class Message
{
public String message { get; set; }
public int code { get; set; }
}
[/csharp]
序列化和反序列化:
[csharp]
Message message = new Message() { code = 0, message = “”};
Console.WriteLine(JsonConvert.SerializeObject(message));
string jsonMessage = “{‘code’:’200′, ‘message’:’操作成功’}”;
Message msg = JsonConvert.DeserializeObject
Console.WriteLine(msg.ToString());
[/csharp]