I have been trying to get this working for 4 days now but I just cant seem to figure it out. Im receiving a json string through an api and want to parse the data into different strings and ints:
Example Json String:
"[{\"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\"}]"
What im trying to convert to:
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; }
}
Code that reads the 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;
}
Now I want to try and Check for each entry if the dat was this week. Then just get the Entry_value of eacht entry from this week and for now show it in a textbox. Any help or tips would be really appreciated.