I've checked, and the collection I'm inputting into the serializer does not have null values, however I get an empty object when I try to serialize it. This only happens when I try to serialize collections of objects, not the individual objects themselves.
Output:
[
[],
[]
]
Code:
public class CustomCommands : List<CustomCommands>
{
[JsonProperty]
public string CommandName { get; set; }
[JsonProperty]
public string CommandResponse { get; set; }
[JsonProperty]
public bool IsModCommand { get; set; }
public static void SaveCommands(List<CustomCommands> CommandsList, string FileName)
{
string JsonString = JsonConvert.SerializeObject(CommandsList, Newtonsoft.Json.Formatting.Indented);
File.WriteAllText(FileName, JsonString);
}
public static List<CustomCommands> LoadCommands(string FileName)
{
string JsonString = File.ReadAllText(FileName);
return JsonConvert.DeserializeObject<CustomCommands>(JsonString);
}
}