tags

System.Text.JSON

Inject a service into a System.Text.Json converter

Most JSON converters are fairly simple, and typically self-contained. But once in a while, you need to do something a little more complex in a converter, and you end up needing to call a service. However, there’s no built-in dependency injection in System.Text.Json converters… How can you access the service you need? There are basically two variants of this problem. One has a simple solution, the other is a bit of a hack…