This article is a mirror article of machine translation, please click here to jump to the original article.

View: 18695|Reply: 0

[Communication] C# parses the second mvc uses Newtonsoft.Json deserialization

[Copy link]
Posted on 2/28/2019 7:40:34 PM | | |
1. I try to useSystem.Web.Script.Serialization deserializes the json data of the Restsharp request in mvc,But it didn't work, and the code was addedusing System.Web.Script.Serialization; , the reference dll is also added, and the code writes:As soon as it runs, an error is reported, and I abandon this method.
2. I tried to useRestSharp's built-in deserialization code:

But. The Deserialize function requires an IRestResponse, is there a way to use RestSharp to deserialize the original string? But it also failed.


3. I solved this problem with Newtonsoft.Json.
Include these namespaces:
And try something like this:
In response. Content, you will get the original result, so just deserialize this string into a JSON object. T in this case is the type you need to deserialize. Sample:

Finally, deserialization is successful.
Does anyone know why the first two failed can reply to me.




Previous:Share the famous foreign ABBYYFineReaderPortable image text recognition software [OCR]
Next:The basic operations of the table on the basis of the database
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com