public static SegregatedEntries FromJson(JObject json) { var e = new SegregatedEntries(); foreach (KeyValuePair <string, JToken> byLevel in json) { GameLevel level = GameLevelHelper.FromString(byLevel.Key).First(); foreach (KeyValuePair <string, JToken> byResult in byLevel.Value.Value <JObject>()) { GameResult result = GameResultHelper.FromStringWordFormat(byResult.Key).First(); e.Add(level, result, Entry.FromJson(byResult.Value.Value <JObject>())); } } return(e); }
public static GameHeader FromJson(JObject json) { var plyCount = json.ContainsKey("ply_count") ? Optional <ushort> .Create(json["ply_count"].Value <ushort>()) : Optional <ushort> .CreateEmpty(); return(new GameHeader( json["game_id"].Value <uint>(), GameResultHelper.FromStringPgnFormat(json["result"].Value <string>()).First(), Date.FromJson(json["date"]), Eco.FromJson(json["eco"]), plyCount, json["event"].Value <string>(), json["white"].Value <string>(), json["black"].Value <string>())); }