2

JSON でエンコードされた文字列があります。次のようになります。

{"jsonrpc":"2.0","メソッド":"テスト","params":["80851851709e01bc9453cced585a7bca","これ"],"id":3}

何らかの理由で C# で「params」にアクセスできません。オブジェクトは null に戻ります。私が使用しているコードは次のとおりです。

public class Access : System.Web.Services.WebService
{

    [WebMethod]
    public string EntryMethod(string json)
    {
        Requests d = JsonConvert.DeserializeObject<Requests>(json);
        return "done";
    }
}
public class Requests
{
    public string jsonrpc { get; set; }
    public string method { get; set; }
    public List<string> param { get; set; }
    public string id { get; set; }
}

何か案は?

4

1 に答える 1

3

タイプミスのため、次のようになります。

ParamS // Add one more S

したがって、クラスは次のようになります。

public class Requests
{
    public string jsonrpc { get; set; }
    public string method { get; set; }
    public List<string> @params { get; set; }
    public string id { get; set; }
}
于 2012-10-03T15:10:09.517 に答える