Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SomePoco
- {
- public int Id{get;set;}
- public string Name{get;set;}
- }
- var p=new SomePoco{Id=4,Name="spender"};
- var json=JsonConvert.SerializeObject(p);
- var pr = JsonConvert.DeserializeObject<SomePoco>(json);
- Console.WriteLine($"Id:{pr.Id}, Name:{pr.Name}");
- class SomeImmutablePoco
- {
- public SomeImmutablePoco(int id, string name)
- {
- Id = id;
- Name = name;
- }
- public int Id{get;}
- public string Name{get;}
- }
- var p = new SomeImmutablePoco(5, "spender's immutable friend");
- var json = JsonConvert.SerializeObject(p);
- var pr = JsonConvert.DeserializeObject<SomeImmutablePoco>(json);
- Console.WriteLine($"Id:{pr.Id}, Name:{pr.Name}");
- class SomeImmutablePoco
- {
- public SomeImmutablePoco(int pocoId, string name)
- {
- Id = pocoId;
- Name = name;
- }
- public int Id{get;}
- public string Name{get;}
- }
- var p = new SomeImmutablePoco(666, "diabolo");
- var json = JsonConvert.SerializeObject(p);
- var pr = JsonConvert.DeserializeObject<SomeImmutablePoco>(json);
- Console.WriteLine($"Id:{pr.Id}, Name:{pr.Name}");
- class SomeImmutablePoco
- {
- public SomeImmutablePoco(int pocoId, string name)
- {
- Id = pocoId;
- Name = name;
- }
- [JsonProperty("pocoId")]
- public int Id { get; }
- public string Name { get; }
- }
Add Comment
Please, Sign In to add comment