没有重载需要2个参数

没有重载需要2个参数

本文介绍了方法'Deserialize'没有重载需要2个参数。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我做了一个返回json值的登录代码,我通过DynamicJsonConverter将其转换但显示错误:方法没有重载'Deserialize'需要2个参数,我的代码在这里:

Hello, I did a code for login which return json value and I convert it through DynamicJsonConverter but it showing error :"No overload for method 'Deserialize' takes 2 arguments" and my code is here :

//login code
      private void button1_Click(object sender, EventArgs e)
      {
          string query = ("aUserName=" + "abc" + "&aPassword=" + "xyz").ToString();
          WebClient wc = new WebClient();
          wc.DownloadStringAsync(new Uri("http://dev.livestuff.com/.LoginAsJSON?" + query));
          wc.DownloadStringCompleted += wc_DownloadStringCompleted;
      }
      /
      /****** Code to serialize the login data *****/
      void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
      {

          var serializer = new JavaScriptSerializer();
          serializer.RegisterConverters(new[] { new DynamicJsonConverter() });

         //showing error in this line
          dynamic obj = serializer.Deserialize(e.Result, typeof(object));

          dynamic dd = obj["HierarchyPosition"];

          if (dd == null)
          {
               MessageBox.Show("Email ID and/or Password is incorrect.");
          }
          else
          {

          }

      }



任何人都可以建议我解决这个问题。

谢谢。


Anyone can suggests me to solve this problem.
Thanks.

推荐答案

JavaScriptSerializer.Deserialize Method (String, Type);

public Object Deserialize(
	string input,
	Type targetType
)

Parameters

input
Type: System.String
The JSON string to deserialize.

targetType
Type: System.Type
The type of the resulting object.





请阅读以获取更多信息:


这篇关于方法'Deserialize'没有重载需要2个参数。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 13:18