使用到动态库Newtonsoft.Json.dll
Json使用举例:
{
"name": "liuhan",
"age": 10,
"skill": ["C++", "C#", "Java", "Delphi"]
}
//自定义结构
public class MyResult
{
public string name{ get; set; }
public int age { get; set; }
public List<string> skill{ get; set; }
}
string str=上面的例子;
//Json串==>实体
MyResult mr= (MyResult)JsonConvert.DeserializeObject(str, typeof(MyResult));
//实体==>Json串
string jsonData = JsonConvert.SerializeObject(mr);