Create class User Firstusing System; namespace JsonTest { public class User { public string name; public string addr; public string phoneNo; public User () { } } }
Than in main functionpublic static void Main (string[] args) { User me = new User (); me.addr = "Taipei"; me.name = "peichun"; me.phoneNo ="123456789"; string jsonString = JsonConvert.SerializeObject (me); Console.WriteLine (jsonString); User you = JsonConvert.DeserializeObject
(jsonString); Console.WriteLine ("Second me : " + you.name); }
Showing posts with label json. Show all posts
Showing posts with label json. Show all posts
2015-09-18
Json.NET using c# - Json Serialize/Deserialize Object
Subscribe to:
Posts (Atom)