Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将JSON数据反序列化到C#_C#_Asp.net_Json_Json.net - Fatal编程技术网

将JSON数据反序列化到C#

将JSON数据反序列化到C#,c#,asp.net,json,json.net,C#,Asp.net,Json,Json.net,我有这个json文件 [{"Ticker":"610-KW", "Ric_Code":null, "Business_Description":"Sultan Center Food Products Company KSCC is a Kuwait-based public shareholding company that holds investments in diverse portfolio of companies within Kuwait and the Middle East

我有这个json文件

[{"Ticker":"610-KW",
"Ric_Code":null,
"Business_Description":"Sultan Center Food Products Company KSCC is a Kuwait-based public shareholding company that holds investments in diverse portfolio of companies within Kuwait and the Middle East, with a specific focus on the retail industry. The Company’s activities include the construction of central markets and restaurants; import, export and marketing of consumer goods; manufacturing of food products; operation of retail supermarkets, restaurants and catering services; trade and installation of telecommunication equipment; trade in readymade garments, shoes, suits, accessories and gifts, and investment in real estate and other industries. The Company also provides consulting and training services. Its business units are structured into seven divisions namely retail, restaurants, trading, fashion, telecom, security and investments. The Company owns and operates subsidiaries in Kuwait, Oman, Bahrain, Lebanon, Jordan, the United Arab Emirates, Egypt and Syria."
,"Arabic_Name":"شركة مركز سلطان للمواد الغذائية (ش.م.ك.مقفلة)","English_Name":"SULTAN CENTER FOOD PRODUCTS COMPANY - K.S.C. (CLOSED)",
"ValidationQuarters":
[{"Period_End_Date":"2012-09-30T00:00:00","Purification_Percentage":0.0,"Status":"Fail","Standard":"QRC","OutStandingShares":578828800,"Treasury_Shares":null,"WhiteList":null}]}
我创建了这个类来反序列化它

public class ValidationQuarter
    {
        public string Period_End_Date { get; set; }
        public double Purification_Percentage { get; set; }
        public string Status { get; set; }
        public string Standard { get; set; }
        public int OutStandingShares { get; set; }
        public int? Treasury_Shares { get; set; }
        public object WhiteList { get; set; }
    }

    public class QueryResult
    {
        public string Ticker { get; set; }
        public object Ric_Code { get; set; }
        public string Business_Description { get; set; }
        public string Arabic_Name { get; set; }
        public string English_Name { get; set; }
        public List<ValidationQuarter> ValidationQuarters { get; set; }
    }
公共类验证季度
{
公共字符串句点\结束\日期{get;set;}
公共双百分比{get;set;}
公共字符串状态{get;set;}
公共字符串标准{get;set;}
公共int未完成共享{get;set;}
公共int?库_共享{get;set;}
公共对象白名单{get;set;}
}
公共类查询结果
{
公共字符串标记器{get;set;}
公共对象Ric_代码{get;set;}
公共字符串业务描述{get;set;}
公共字符串阿拉伯文名称{get;set;}
公共字符串英文名称{get;set;}
公共列表验证区{get;set;}
}
当调用此代码时

string result = c.getResultsByTicker(reqStr);

                QueryResult qr = Newtonsoft.Json.JsonConvert.DeserializeObject<QueryResult>(result);
string result=c.getResultsByTicker(reqStr);
QueryResult qr=Newtonsoft.Json.JsonConvert.DeserializeObject(结果);
这引起了一个错误

无法将JSON数组反序列化为类型“webservicery.QueryResult”。 第1行,位置1


JSON表示QueryResult对象的数组。您正在尝试将它们反序列化为单个实例。您只需更改为:

List<QueryResult> qrs = JsonConvert.DeserializeObject<List<QueryResult>>(result);
List qrs=JsonConvert.DeserializeObject(结果);