Skip to content

Commit

Permalink
Update README.md JSON Source Generator (#1793)
Browse files Browse the repository at this point in the history
JsonSerializerOptions.AddContext is obsolete. (https://learn.microsoft.com/en-us/dotnet/api/system.text.json.jsonserializeroptions.addcontext?view=net-8.0)

Co-authored-by: Chris Pulman <chris.pulman@yahoo.com>
  • Loading branch information
Digifais and ChrisPulman authored Sep 1, 2024
1 parent c05a599 commit 74f9d5e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,9 @@ public class Foo
To apply the benefits of the new [JSON source generator](https://devblogs.microsoft.com/dotnet/try-the-new-system-text-json-source-generator/) for System.Text.Json added in .NET 6, you can use `SystemTextJsonContentSerializer` with a custom instance of `RefitSettings` and `JsonSerializerOptions`:

```csharp
var options = new JsonSerializerOptions();
options.AddContext<MyJsonSerializerContext>();
var options = new JsonSerializerOptions() {
TypeInfoResolver = MyJsonSerializerContext.Default
};

var gitHubApi = RestService.For<IGitHubApi>("https://api.github.com",
new RefitSettings {
Expand Down

0 comments on commit 74f9d5e

Please sign in to comment.