I'm an idiot, they store encoded data for towers, we dont need a separate object unless we want to
This commit is contained in:
@@ -11,13 +11,12 @@ namespace TOOHUCardAPI.Data.JsonConverters
|
||||
{
|
||||
public override void WriteJson(JsonWriter writer, RankEntryDTO value, JsonSerializer serializer)
|
||||
{
|
||||
List<RankCardDTO> cards = value.Cards;
|
||||
Dictionary<string, string> cards = value.Cards;
|
||||
value.Cards = null;
|
||||
JObject jo = JObject.FromObject(value);
|
||||
for (int i = 0; i < cards.Count; i++)
|
||||
foreach (var kv in cards)
|
||||
{
|
||||
jo[$"card{i}"] = JObject.FromObject(cards[i]);
|
||||
|
||||
jo[kv.Key] = kv.Value;
|
||||
}
|
||||
jo.WriteTo(writer);
|
||||
}
|
||||
@@ -29,7 +28,8 @@ namespace TOOHUCardAPI.Data.JsonConverters
|
||||
RankEntryDTO dto = new RankEntryDTO();
|
||||
serializer.Populate(reader, dto);
|
||||
dto.Cards = jo.Properties().Where(prop => prop.Name.Contains("card"))
|
||||
.Select(i => i.Value.ToObject<RankCardDTO>()).ToList();
|
||||
.Select(i => KeyValuePair.Create(i.Name, i.Value))
|
||||
.ToDictionary(kv => kv.Key, kv => kv.Value.ToObject<string>());
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user