我已经试着让它工作了4天了,但我似乎就是想不出来。我正在通过api接收json字符串,并希望将数据解析为不同的字符串和into:
Json字符串示例:
"[{\"Entry_number\":\"4\",\"Entry_date\":\"2019-01-10 18:22:55\",\"Customer_number\":\"16\",\"Entry_value\":\"13\",\"Comment\":\"Nu gaat ie t GVD doen\"},
{\"Entry_number\":\"5\",\"Entry_date\":\"2019-01-12 14:34:23\",\"Customer_number\":\"16\",\"Entry_value\":\"10\",\"Comment\":\"TextBox\"},
{\"Entry_number\":\"6\",\"Entry_date\":\"2019-01-12 14:34:31\",\"Customer_number\":\"16\",\"Entry_value\":\"10\",\"Comment\":\"Onrustig\"},
{\"Entry_number\":\"7\",\"Entry_date\":\"2019-01-12 14:34:37\",\"Customer_number\":\"16\",\"Entry_value\":\"10\",\"Comment\":\"Ziek\"}]"
我想要转换成:
public class SleepEntry
{
string Entry_number;
string Entry_date;
string Customer_number;
string Entry_value;
string Comment;
public string Entry_number1 { get => Entry_number; set => Entry_number = value; }
public string Entry_date1 { get => Entry_date; set => Entry_date = value; }
public string Customer_number1 { get => Customer_number; set => Customer_number = value; }
public string Entry_value1 { get => Entry_value; set => Entry_value = value; }
public string Comment1 { get => Comment; set => Comment = value; }
}
public class SleepData
{
private List<SleepEntry> plants;
public List<SleepEntry> Plants { get => plants; set => plants = value; }
}
读取json的代码:
public void Get_Monthly_Data()
{
StreamReader reader = new StreamReader(@"C:\Users\Ruben\source\repos\Health App Goede\Health App Goede\Resources\Cutstomer_ID.txt");
Customernumber = reader.ReadLine();
reader.Close();
//string json = entrys();
//convert json to series objects
SleepData sleepdata = JsonConvert.DeserializeObject<SleepData>(entrys());
}
public string entrys()
{
string json = get.get_customer_monitoring_entry("sleep", Customernumber);
return json;
}
现在,我想尝试检查每个条目是否为本周的日期。然后,从本周开始获取每个条目的Entry_value,现在将其显示在文本框中。任何帮助或提示都将不胜感激。
https://stackoverflow.com/questions/54167097
复制相似问题