When I run this code i get a Null Reference exception error when I try to add a tag to the tagCollection. I'm pretty it's an issue with how I've declared tagCollection but I'm not sure where I'm going wrong.
The 2 classes setup are to enable me serialize the collection back to a JSON file once I have finished collecting my data.
class TagCollection
{
[JsonProperty("tags")]
public List<Tag> Tags { get; set; }
}
public class Tag
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("value")]
public string Value { get; set; }
}
private TagCollection tagCollection;
private void createCollection(){
tagCollection.Tags.Add(
new Tag { Name = "Test", Id = "tag1", Value = "145" }
);
}