Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.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
如何在C#Asp.Net中从JSON结果字符串中检索值_C#_Asp.net - Fatal编程技术网

如何在C#Asp.Net中从JSON结果字符串中检索值

如何在C#Asp.Net中从JSON结果字符串中检索值,c#,asp.net,C#,Asp.net,如何解析下面的JSon字符串以获取RESULT&ERROR的值 { "RESPONSE": [ { "DT": "20210317", "I_NO": "1031021", "C_NO": "1021", "RESULT"

如何解析下面的JSon字符串以获取RESULT&ERROR的值

{
    "RESPONSE": [
        {
            "DT": "20210317",
            "I_NO": "1031021",
            "C_NO": "1021",
            "RESULT": "E",
            "DCODE": "2-B1",
            "ERROR": "[AMT] is mandatory."
        }
    ]
}
创建用于反序列化的c#类

public class RESPONSE
{
    public string DT { get; set; }
    public string I_NO { get; set; }
    public string C_NO { get; set; }
    public string RESULT { get; set; }
    public string DCODE { get; set; }
    public string ERROR { get; set; }
}

public class Root
{
    public List<RESPONSE> RESPONSE { get; set; }
}
公共类响应
{
公共字符串DT{get;set;}
公共字符串I_NO{get;set;}
公共字符串C_NO{get;set;}
公共字符串结果{get;set;}
公共字符串DCODE{get;set;}
公共字符串错误{get;set;}
}
公共类根
{
公共列表响应{get;set;}
}
然后用

var response=JsonConvert.DeserializeObject(jsonString);

这是否回答了您的问题?
var response = JsonConvert.DeserializeObject<Root>(jsonString);