I need to serialize some entity classes to JSON, using Json.NET. In order to customize the names of the properties, I use the [JsonProperty]
attribute like this:
[JsonProperty("lastName")]
public string LastName { get; set; }
The problem is, I'd prefer not to have any JSON-related attributes in my entities... Is there a way to externalize the annotations somehow, so that they don't clutter my entities?
Using XmlSerializer
, it can be done easily with the XmlAttributeOverrides
class. Is there something similar for Json.NET ?