Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/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#class并不等同于json结构。复制json,在VisualStudio的“查看”或“编辑”菜单中,有一个“粘贴”特殊菜单单击此处,它将为复制的json结构创建c#类。此外,您还应该删除执行构造函数。我强烈建议不要直接使用该C#,而是使用C_C#_Json_Interface - Fatal编程技术网

我强烈感觉c#class并不等同于json结构。复制json,在VisualStudio的“查看”或“编辑”菜单中,有一个“粘贴”特殊菜单单击此处,它将为复制的json结构创建c#类。此外,您还应该删除执行构造函数。我强烈建议不要直接使用该C#,而是使用C

我强烈感觉c#class并不等同于json结构。复制json,在VisualStudio的“查看”或“编辑”菜单中,有一个“粘贴”特殊菜单单击此处,它将为复制的json结构创建c#类。此外,您还应该删除执行构造函数。我强烈建议不要直接使用该C#,而是使用C,c#,json,interface,C#,Json,Interface,我强烈感觉c#class并不等同于json结构。复制json,在VisualStudio的“查看”或“编辑”菜单中,有一个“粘贴”特殊菜单单击此处,它将为复制的json结构创建c#类。此外,您还应该删除执行构造函数。我强烈建议不要直接使用该C#,而是使用C#惯用名称,并使用[JsonProperty]指定要在JSON中使用/解析的名称。这是一个很好的建议,但对于大多数新手用户来说,这往往是一个过渡性的问题。不过,要养成好习惯——我不是建议更改示例代码,而是建议在答案的底部添加一个建议。我强烈建议


我强烈感觉c#class并不等同于json结构。复制json,在VisualStudio的“查看”或“编辑”菜单中,有一个“粘贴”特殊菜单单击此处,它将为复制的json结构创建c#类。此外,您还应该删除执行构造函数。我强烈建议不要直接使用该C#,而是使用C#惯用名称,并使用
[JsonProperty]
指定要在JSON中使用/解析的名称。这是一个很好的建议,但对于大多数新手用户来说,这往往是一个过渡性的问题。不过,要养成好习惯——我不是建议更改示例代码,而是建议在答案的底部添加一个建议。我强烈建议不要直接使用该C,而是给东西取C习惯名称,并使用
[JsonProperty]
指定要在JSON中使用/解析的名称。这是一个很好的建议,但对于大多数新手用户来说,这往往是一个过渡性的问题。不过要养成好习惯——我不是建议更改示例代码,而是建议在答案的底部添加一个建议。
string jsonText = File.ReadAllText(jsonFilePath);
Execution test = JsonConvert.DeserializeObject<Execution>(jsonText);
    foreach (string eID in test.E_id)
    {
        Console.WriteLine(eID);
    }
public class Execution
{
    public string Usr_id { get; private set; }
    public string Patient_id { get; private set; }
    public List<string> E_id { get; private set; }
    public List<string> E_title { get; private set; }
    public List<string> E_description { get; private set; }
    public List<string> E_date { get; private set; }
    public List<string> E_delete { get; private set; }

    public Execution(string usr_id, string patient_id, List<string> e_id, List<string> e_title, List<string> e_description,
    List<string> e_date, List<string> e_delete)
    {
        Usr_id = usr_id;
        Patient_id = patient_id;
        E_id = e_id;
        E_title = e_title;
        E_description = e_description;
        E_date = e_date;
        E_delete = e_delete;
    }
}
{
    "usr_id":"573",
    "patient_id":"170510024",
    "executions":[
        {
            "id":"SF70H",
            "title":"Verbandswechsel",
            "description":"Verband des rechten Armes wechseln",
            "date":"2017-07-28T12:00:00.000Z",
            "delete":false
        },
        {
            "id":"SF18H",
            "title":"Physiotherapie",
            "description":"Beweglichkeit des Knies wiederherstellen",
            "date":"2017-07-28T14:00:00.000Z",
            "delete":false
        }
    ]
public class Execution
{
    public string id { get; set; }
    public string title { get; set; }
    public string description { get; set; }
    public DateTime date { get; set; }
    public bool delete { get; set; }
}

public class Test
{
    public string usr_id { get; set; }
    public string patient_id { get; set; }
    public List<Execution> executions { get; set; }
}
Test test = JsonConvert.DeserializeObject<Test>(jsonText);
public class Rootobject
{
    public string usr_id { get; set; }
    public string patient_id { get; set; }
    public Execution[] executions { get; set; }
}

public class Execution
{
    public string id { get; set; }
    public string title { get; set; }
    public string description { get; set; }
    public DateTime date { get; set; }
    public bool delete { get; set; }
}
public class Rootobject
{
    [JsonProperty("usr_id")]
    public string UserId { get; set; }
    [JsonProperty("patient_id")]
    public string PatientId { get; set; }
    [JsonProperty("executions ")]
    public Execution[] Executions { get; set; }
}

public class Execution
{
    [JsonProperty("id")]
    public string Id { get; set; }
    [JsonProperty("title")]
    public string Title { get; set; }
    [JsonProperty("description")]
    public string Description { get; set; }
    [JsonProperty("datee")]
    public DateTime Date { get; set; }
    [JsonProperty("delete")]
    public bool Delete { get; set; }
}
public class ExecutionOrder
{
    public string Usr_id { get; set; }
    public string Patient_id { get; set; }
    public List<Execution> Executions { get; set; }

    public ExecutionOrder(string usr_id, string patient_id, List<Execution> executions)
    {
        Usr_id = usr_id;
        Patient_id = patient_id;
        Executions = executions;
    }

}

public class Execution
{
    public string E_id { get; set; }
    public string E_title { get; set; }
    public string E_description { get; set; }
    public string E_date { get; set; }
    public bool E_delete { get; set; }

    public Execution(string e_id, string e_title, string e_description, string e_date, bool e_delete)
    {
        E_id = e_id;
        E_title = e_title;
        E_description = e_description;
        E_date = e_date;
        E_delete = e_delete;
    }

}
ExecutionOrder test = JsonConvert.DeserializeObject<ExecutionOrder>(jsonText);
test.Executions.ForEach(delegate(Execution exec)
{
    Console.WriteLine(test.Usr_id);
    Console.WriteLine(test.Patient_id);
    Console.WriteLine(exec.E_id);
    Console.WriteLine(exec.E_title);
    Console.WriteLine(exec.E_description);
    Console.WriteLine(exec.E_date);
    Console.WriteLine(exec.E_delete);
    Console.WriteLine();
});