正确的Json例子,解析与实例化

使用到动态库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);

猜你喜欢

转载自blog.csdn.net/neo9781467/article/details/87358289
今日推荐