Например:
Код: Выделить всё
public class Employee
{
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
[JsonProperty(PropertyName = "id")]
public int EmployeeId { get; set; }
[JsonProperty(PropertyName = "supervisor")]
public string Supervisor { get; set; }
}
var employee = new Employee { Name = "John Doe", EmployeeId = 5, Supervisor = "Jane Smith" };
var boss = new Employee { Name = "Jane Smith", EmployeeId = 1 };
Код: Выделить всё
{ "id":"5", "name":"John Doe", "supervisor":"Jane Smith" }
Код: Выделить всё
{ "id":"1", "name":"Jane Smith" }
Подробнее здесь: https://stackoverflow.com/questions/235 ... izing-json