RestSharp serialization to JSON, object is not using SerializeAs attribute as expected

前端 未结 5 1730
北荒
北荒 2020-11-30 11:36

I am using RestSharp (version 104.4 via NuGet) to make calls to a Rest Web Service. I have designed a set of objects (POCO) which matches resources exposed

5条回答
  •  离开以前
    2020-11-30 11:59

    In RestSharp 104.4, the default JsonSerializer doesn't use the [SerializeAs] attribute, as seen by reviewing the source code.

    One workaround to this is to create a custom serializer that uses the Json.NET JsonSerializer (a good example is here) and then decorate your properties with the [JsonProperty] attribute, like so:

    
    Public Property EmailAddress As String
    

提交回复
热议问题