Json 程序集:Newtonsoft.Json

 

程序集:Newtonsoft.Json

引用空间:namespace Newtonsoft.Json

 

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace JSON
 8 {
 9     class Program
10     {
11         static void Main(string[] args)
12         {
13             Users user=new Users(){Name = "小明",Age = 56,Sex = true};
14             string str = Newtonsoft.Json.JsonConvert.SerializeObject(user);//"{\"Name\":\"小明\",\"Age\":56,\"Sex\":true}"
15         }
16     }
17     public class Users
18     {
19         public string Name { get; set; }
20         public byte Age { get; set; }
21         public bool Sex { set; get; }
22     }
23 }
方法1:把对像(数组,集合,对象、、、、、、、、)转成字符串类型:JsonConvert.SerializeObject(对象);

 

posted on 2015-03-25 11:13  高达  阅读(309)  评论(0)    收藏  举报

导航