Search code examples
c#restsharpsystem.text.json

RestSharp v107: setting Json serialization options


I'm using the new RestSharp v107, which started using the System.Text.Json classes to manage JSON (de)serialization.

This being the case, I thought we would be able to provide our own instance of JsonSerializerOptions to customize how serialization is handled, however I cannot see any settings in the RestClientOptions object to set the json serialization options. Is there a way to do this?


Solution

  • Well, I found out the answer shortly after posting.

    All you have to do is:

    httpClient.UseSystemTextJson(new JsonSerializerOptions() { ... });
    

    and it's done, simple as that