Skip to content

Instantly share code, notes, and snippets.

@beachside-project
Created April 15, 2016 11:52
Show Gist options
  • Save beachside-project/ad62ffea9f640dd939db2c5ed79c7d3c to your computer and use it in GitHub Desktop.
Save beachside-project/ad62ffea9f640dd939db2c5ed79c7d3c to your computer and use it in GitHub Desktop.
jsonDemo_person2_attribute
public class Person
{
[JsonProperty(PropertyName = "firstName")]
public string FirstName { get; set; }
[JsonProperty(PropertyName = "lastName")]
public string LastName { get; set; }
[JsonProperty(PropertyName = "age")]
public int Age { get; set; }
[JsonProperty(PropertyName = "favorites")]
public string[] Favorites { get; set; }
[JsonProperty(PropertyName = "phones")]
public List<Phone> Phones { get; set; }
[JsonIgnore]
[JsonProperty(PropertyName = "fullName")]
public string FullName => $"{FirstName} {LastName}";
}
public class Phone
{
[JsonProperty(PropertyName = "phoneNumber")]
public string PhoneNumber { get; set; }
[JsonProperty(PropertyName = "modelName")]
public string ModelName { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment