JavaScriptSerializer namespace issue

前端 未结 5 586
清酒与你
清酒与你 2021-01-17 10:46

I am having a problem trying to implement the JavaScriptSerializer to parse a JSON string received from a server.

I implemented the following code:

相关标签:
5条回答
  • 2021-01-17 11:12
    System.Web.Script.Serialization.JavaScriptSerializer oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
    var dict = oSerializer.Deserialize<Dictionary<string, object>>(responseFromServer);
    

    This will help you to get the value

    0 讨论(0)
  • 2021-01-17 11:12

    I have had this problem and I added project reference for System.Web.Extensions , try adding that reference to your project and see if it helps

    0 讨论(0)
  • 2021-01-17 11:19

    Add Reference System.Web.Extensions

    then type using System.Web.Script.Serialization;

    Now you should get JavaScriptSerializer valid.

    You can use better approach by adding Newtonsoft.Json.dll through

    Add Reference. See details here : http://json.codeplex.com/

    0 讨论(0)
  • 2021-01-17 11:25

    JavaScriptSerializer is situated in System.Web.Extensions Assembly. You should add it to your project references.

    You can get this information in MSDN

    Assembly: System.Web.Extensions (in System.Web.Extensions.dll)

    0 讨论(0)
  • 2021-01-17 11:27

    install Desharp package you can use this command in package manager console

    Install-Package Desharp -Version 1.2.11

    0 讨论(0)
提交回复
热议问题