If I receive JSON which is beyond my control, which has a property as follows.
{"allow":"true"}
and I want that to map to a bool property in C#.
I saw that I can do similar for numbers using the attribute
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
but how can I do that for booleans?
Edit:
I am not sure why this is closed because of a duplicate question, since the other question focuses on converting from ints to bools
Ok, it seems like this functionality is not built in but is easy to implement. https://github.com/dotnet/runtime/issues/43587#issuecomment-780031498
Would have to create a custom converter as follows (taken from the link).