0

I'm serializing/deserializing complex object and I have to use several custom Json Converters. Each custom converter is assigned to related interface by attribute - [JsonConverter(typeof(MySpecialConverter))].

Now I need access my service in overrided ReadJson method in custom JsonConvert class. I found lot of "solutions" but most of them doesn't use assigned converterts by attribute, so it's not working for my case.

What should be proper approach to achive my needs?

I use Newtonsoft.Json 13.0.1

  • Do any of the solutions from [Adding parameter to Json converter during deserialization with converter defined for property](https://stackoverflow.com/q/75006063/3744182) meet your needs? Would something like `ConverterReplacingContractResolver` from [this answer](https://stackoverflow.com/a/75009977/3744182) work for you? The answer would need to be generalized to handle converters applied to types as well as converters applied to properties. – dbc Mar 27 '23 at 14:52
  • Or does [How to inject dependency in Newtonsoft JsonConverter in .NET Core 3.1](https://stackoverflow.com/q/69520303) meet your needs? – dbc Mar 27 '23 at 19:41
  • Or if none of those work for you, might you please [edit] your question to include some additional details about what you are trying to do, ideally as a simplified [mcve]? – dbc Mar 27 '23 at 20:02

0 Answers0