Owez
Owez
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
i guess not
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
any more critiques?
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
yep they should all use the same time
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
im tracking each update not each time ive possibly captured it
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
rather than having to linear search through each snapshot and then see if theres a title in there or if its not been captured or not been updated
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
a lot easier with ISO alphabetically sorted dates
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
title.current()
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
and Elements means each is generalised
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
metadata captures not perfect so sometimes only certain things are either updated or remain unchanged
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
the only other way to do it is like that original Snapshot class in a list but then you lose the hashtable
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
I'm writing a youtube archiver which can snapshot metadata at different places in time
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
Timeseries data
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
Did not think about that
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
I need it as a class because it's got related methods otherwise it'd just be a Dictionary. In rust this would look like
#[derive(Serialize, Deserialize)]
pub struct Elements<T>(HashMap<DateTime<Utc>, T>)
#[derive(Serialize, Deserialize)]
pub struct Elements<T>(HashMap<DateTime<Utc>, T>)
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
How do I flatten this so there's no {"Values": [data here]} so its only {[data here]}
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
This is what I actually needed help with haha:
public class Elements<T>
{
public Dictionary<DateTime, T> Values { get; set; }

public Elements(Dictionary<DateTime, T> values)
{
Values = values;
}

public static Elements<T> NewTest(string isoDateString, T firstValue)
{
DateTime parsedDate = DateTime.Parse(isoDateString);
Dictionary<DateTime, T> values = new Dictionary<DateTime, T>
{
{ parsedDate, firstValue }
};
return new Elements<T>(values);
}
}
public class Elements<T>
{
public Dictionary<DateTime, T> Values { get; set; }

public Elements(Dictionary<DateTime, T> values)
{
Values = values;
}

public static Elements<T> NewTest(string isoDateString, T firstValue)
{
DateTime parsedDate = DateTime.Parse(isoDateString);
Dictionary<DateTime, T> values = new Dictionary<DateTime, T>
{
{ parsedDate, firstValue }
};
return new Elements<T>(values);
}
}
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
Yep seems to work
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
Had the wrong test case
48 replies
CC#
Created by Owez on 6/30/2023 in #help
Implementing JsonConverter to simplify ser/de
Yeah the JSON is for a class with a dictionary inside (called Elements), posted the wrong bit but I was debugging assuming that JSON which is why I couldn't get it to work
48 replies