using Newtonsoft.Json.Linq; using System.Collections.Generic; namespace EDJournal { public class RedeemVoucherEntry : Entry { protected override void Initialise() { Amount = JSON.Value("Amount"); Type = JSON.Value("Type"); /* according to API, there should be a Factions structure */ JToken factions = JSON.GetValue("Factions"); if (factions != null) { foreach (JObject faction in factions.Children()) { string faction_name = faction.Value("Faction"); if (faction_name == null || faction_name.Length <= 0) { continue; } Factions.Add(faction_name); } } /* but there also might be just a Faction entry */ string single_faction = JSON.Value("Faction"); if (single_faction != null) { Factions.Add(single_faction); } } public int Amount { get; set; } = 0; public string Type { get; set; } = "Bounty"; public List Factions { get; set; } = new List(); } }