public static JsonObject ToJson(Dominion.GameDescription gameDescription) { JsonObject root = new Windows.Data.Json.JsonObject(); root.Add(jsonNameUseShelters, JsonValue.CreateBooleanValue(gameDescription.useShelters)); root.Add(jsonNameUseColonyAndPlatinum, JsonValue.CreateBooleanValue(gameDescription.useColonyAndPlatinum)); string banePileName = gameDescription.BanePileProgrammaticName(); if (banePileName != null) { root.Add(jsonNameBane, JsonValue.CreateStringValue(banePileName)); } JsonArray kingdomArray = new JsonArray(); foreach (var cardName in gameDescription.KingdomPileProgramaticNames()) { kingdomArray.Add(JsonValue.CreateStringValue(cardName)); } root.Add(jsonNameKingdomPiles, kingdomArray); JsonArray eventArray = new JsonArray(); foreach (var cardName in gameDescription.EventProgramaticNames()) { eventArray.Add(JsonValue.CreateStringValue(cardName)); } root.Add(jsonNameEvents, eventArray); JsonArray projectArray = new JsonArray(); foreach (var cardName in gameDescription.ProjectProgramaticNames()) { projectArray.Add(JsonValue.CreateStringValue(cardName)); } root.Add(jsonNameProjects, projectArray); JsonArray landmarkArray = new JsonArray(); foreach (var cardName in gameDescription.LandmarkProgramaticNames()) { projectArray.Add(JsonValue.CreateStringValue(cardName)); } root.Add(jsonNameLandmarks, projectArray); return(root); }