Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/291.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/3/arrays/13.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# C用一个数组和一个布尔值反序列化Json字符串_C#_Arrays_Json_Json.net_Deserialization - Fatal编程技术网

C# C用一个数组和一个布尔值反序列化Json字符串

C# C用一个数组和一个布尔值反序列化Json字符串,c#,arrays,json,json.net,deserialization,C#,Arrays,Json,Json.net,Deserialization,我试图反序列化一个json字符串,但只有bool值附加到我的类中,因为数组值总是空的 public static EmployeeInformation GetEngineerAdditionInfo(ProjectUserRoles role) { EmployeeInformation engineerAdditionalInfo = new EmployeeInformation();

我试图反序列化一个json字符串,但只有bool值附加到我的类中,因为数组值总是空的

            public static EmployeeInformation GetEngineerAdditionInfo(ProjectUserRoles role)
            {
                    EmployeeInformation engineerAdditionalInfo = new EmployeeInformation();
                    var apiBaseUri = string.Empty;
                    apiBaseUri = "https:example.com";
                    Uri newUri = new Uri(apiBaseUri);
                    var httpWebRequest = (HttpWebRequest)WebRequest.Create(newUri);
                    httpWebRequest.Method = WebRequestMethods.Http.Get;
                    httpWebRequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
                    using (var response = (HttpWebResponse)httpWebRequest.GetResponse())
                    {
                        using (var reader = new StreamReader(response.GetResponseStream()))
                        {
                            string line = reader.ReadToEnd();

                            engineerAdditionalInfo = JsonConvert.DeserializeObject<EmployeeInformation>(line);
                        }
                     }
              }
我错过什么了吗?或者有没有其他方法可以从json字符串获取数组列表

提前感谢,


迪内什。

这只是一个猜测,但我想你忘了将你的员工基本细节公之于众:

public class EmployeeInformation
{
    public bool IsSuccess { get; set; }

    public List<EmployeeBasicDetails> EmployeeBasicDetails { get; set; }
}

public class EmployeeBasicDetails
{
    public int UserId { get; set; }

    public string EmployeeId { get; set; }

    public string EmailId { get; set; }

    public string EmployeeName { get; set; }
}

希望有帮助

EmployeeInformation中的EmployeeBasicDetails属性不是公共的。如果这是问题,请检查。非常感谢。你救了我一天..:它起作用了
{"IsSuccess":true,"EmployeeBasicDetails":[{"UserId":124,"EmployeeId":"SS124","EmailId":"example@example.com","EmployeeName":"Example"},{"UserId":125,"EmployeeId":"SS125","EmailId":"example@example.com","EmployeeName":"Example"},{"UserId":126,"EmployeeId":"SS126","EmailId":"example@example.com","EmployeeName":"Example"},{"UserId":127,"EmployeeId":"SS127","EmailId":"example@example.com","EmployeeName":"Example"}]}
public class EmployeeInformation
{
    public bool IsSuccess { get; set; }

    public List<EmployeeBasicDetails> EmployeeBasicDetails { get; set; }
}

public class EmployeeBasicDetails
{
    public int UserId { get; set; }

    public string EmployeeId { get; set; }

    public string EmailId { get; set; }

    public string EmployeeName { get; set; }
}