Issue
I have the following code in an ASP.NET Web API 2 app:
[DataMember(Name = "override")]
public bool? _override;
But the JSON I receive has that member named _override, not override. How can I change the naming in the JSON?
Solution
As asp.Net web API 2 uses Json.NET
internally for json serialization/deserialization,
JsonProperty
attribute can be used to override property name on serialization.
so [JsonProperty(PropertyName = "override")]
should do the trick.
Thanks.
Answered By - shakib Answer Checked By - Cary Denson (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.