using System.Collections.Generic;
using System.Threading.Tasks;
public static void Main()
var json = "{\"settings\":{\"elements\":{\"h1\":{\"font-size\":\"30px\",\"color\":\"#1094C8\",\"white-space\":\"nowrap\",\"font-weight\":500,\"pagebreak-before\":\"always/never/auto\",\"pagebreak-after\":\"always/never/auto\",\"pagebreak-within\":\"never/auto\"},\"h2\":{\"font-size\":\"22px\",\"margin-top\":0,\"font-weight\":600,\"line-height\":1.2,\"color\":\"#707070\"},\"h3\":{\"font-size\":\"20px\",\"margin-top\":0,\"font-weight\":600,\"line-height\":1.2,\"color\":\"#707070\"},\"p\":{\"line-height\":1.5,\"color\":\"#707070\",\"text-align\":\"justify\"},\"table\":{\"color\":\"inherit\",\"width\":\"100%\",\"text-align\":\"left\"},\"body\":{\"color\":\"#707070\",\"font-size\":\"13px\",\"font-family\":\"arial\"},\"li\":{\"color\":\"#707070\",\"font-size\":\"13px\",\"font-family\":\"arial\"},\"logo\":{\"border-bottom-color\":\"#eaeae4\",\"border-bottom-style\":\"solid\"},\"image-settings\":{\"width\":\"500px\",\"margin\":\"5pxauto\",\"display\":\"block\",\"float\":\"none\",\"vertical-align\":\"top\",\"position\":\"relative\",\"text-align\":\"justify\",\"max-width\":\"70%\"}},\"header\":{\"img-width\":\"12px\",\"img-height\":\"2px\"},\"footer\":{\"img-width\":\"12px\",\"img-height\":\"2px\"},\"banner\":{\"visible\":true,\"position\":\"allpages/firstPage\"},\".banner-header\":{\"display\":\"block!important\",\"height\":\"50px;\",\"width\":\"100%;\",\"margin-bottom\":\"20px;\"},\"layout\":{\"top-margin\":\"10px\",\"left-margin\":\"10px\",\"width\":\"500px\"},\"sections\":{\".commentary-block\":{\"page-break-after\":\"auto|always|avoid|left|right\",\"page-break-before\":\"auto|always|avoid|left|right\",\"page-break-inside\":\"auto|avoid\"},\".logo\":{\"border-bottom-color\":\"#eaeae4;\",\"border-bottom-style\":\"solid\"},\".logoimg\":{\"height\":\"50px\"},\".logo#sub\":{\"float\":\"right\"}}},\"media\":{\"word\":{\"elements\":{\"h1\":{\"font-size\":\"30px\",\"color\":\"#1094C8\",\"white-space\":\"nowrap\",\"font-weight\":700}},\"layout\":{\"top-margin\":\"10px;\",\"left-margin\":\"10px;\"},\"table\":{\"color\":\"inherit\",\"width\":\"100%\",\"text-align\":\"left\"}},\"pdf\":{}}}";
var model = JsonConvert.DeserializeObject<CssContentModel>(json);
var wordH1Configs = model.GetWordH1();
foreach (var wordH1Config in wordH1Configs)
Console.WriteLine("Key: " + wordH1Config.Key + " Value: " + wordH1Config.Value);
Console.WriteLine(JsonConvert.SerializeObject(model));
public class CssContentModel
[JsonProperty("settings")]
public Settings Settings { get; set; }
public Media Media { get; set; }
public Dictionary<string, string> GetWordH1()
var foundValues = new Dictionary<string, string>();
if (Media?.Word?.Elements?.ContainsKey("h1") == true)
var foundValuesInMedia = Media.Word.Elements.First(x => x.Key == "h1").Value;
foreach (var value in foundValuesInMedia)
foundValues.Add(value.Key, value.Value);
if (Settings?.Elements?.ContainsKey("h1") == true)
var foundValuesInSettings = Settings.Elements.First(x => x.Key == "h1").Value;
foreach (var value in foundValuesInSettings)
if (!foundValues.ContainsKey(value.Key))
foundValues.Add(value.Key, value.Value);
[JsonProperty("elements")]
public Dictionary<string, Dictionary<string, string>> Elements { get; set; }
public Dictionary<string, string> Header { get; set; }
public Dictionary<string, string> Banner { get; set; }
public Dictionary<string, string> Layout { get; set; }
[JsonProperty("sections")]
public Dictionary<string, Dictionary<string, string>> Sections { get; set; }
public Word Word { get; set; }
public Pdf Pdf { get; set; }
public Ppt Ppt { get; set; }
[JsonProperty("elements")]
public Dictionary<string, Dictionary<string, string>> Elements { get; set; }
public Dictionary<string, string> Header { get; set; }
public Dictionary<string, string> Banner { get; set; }