Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 1.08 KB

poco-mapping.md

File metadata and controls

31 lines (22 loc) · 1.08 KB

Mapping JSON fields to POCO properties

While not an actually responsibility of the LINQ provider, the default serialization library, Newtonsoft.Json, supports field the following serialization attributes:

Please refer to their documentation for issues regarding serialization.

Mixing of attribute types is supported by Newtonsoft.Json. Here is an example of mixing JsonPropertyAttribute and DataMemberAttribute:

public class Beer
{
    [Key]
    [JsonProperty("name")]
    public string Name { get; set; }

    [DataMember(Name = "abv")]
    public decimal Abv { get; set; }

    [JsonProperty("ibu")]
    public decimal Ibu { get; set; }

    // ...
}

See Custom JSON Serializers for information on using a custom JSON serializer.