When upgrading an ASP.NET Core 2.1 application to 3.1, I encountered an error : The JSON value could not be converted to System.Nullable. What is going on and how should this problem be solved?
Asked
Active
Viewed 2,064 times
-1
-
2Does this answer your question? [The JSON value could not be converted to System.Nullable\[System.Int32\]](https://stackoverflow.com/questions/58885384/the-json-value-could-not-be-converted-to-system-nullablesystem-int32) – CaveCoder Feb 25 '21 at 12:50
-
Other commentor answered your question, but in future please post code. – Tom Feb 25 '21 at 16:02
-
Just take a look at the solution here. – Mahmmoud Kinawy Dec 25 '22 at 13:26
2 Answers
1
I think you use the old jsonoption in ConfigureService. Since starting from ASP.NET Core 3.0, its default built-in JSON serialization and deserialization library is System.Text.Json. This library does not implement JSON conversion of these special data types like Json.NET. , so you can add nuget package newtonsoft to replace the built-in JSON serialization library System.Text.Json. And configure it in startup.
services.AddControllers().AddNewtonsoftJson();

Karney.
- 4,803
- 2
- 7
- 11
0
I got this error too. The problem is that the information from the front is not in the correct format and if you are using frombody .net throws this error when it cannot convert it. I had this mistake in the byte array.
-
This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/31691147) – Dan May 11 '22 at 12:29