Newtonsoft.Json Newtonsoft.Json Newtonsoft.Json.Bson Newtonsoft.Json.Converters Newtonsoft.Json.Linq Newtonsoft.Json.Schema Newtonsoft.Json.Serialization void Main() { string Rendered = JsonFromTemplate(Globals.strTemplate, Globals.strData); } // render adaptive card JSON public string JsonFromTemplate(string strTemplate, string strData) { string output = ""; // first create JSON objects out of the input JObject Template = JObject.Parse(strTemplate); JObject Data = JObject.Parse(strData); // body = array of jobjects JArray TemplateBody = (JArray)Template["body"]; TemplateBody.Dump(); return output; } // set up global statics public class Globals { public static Dictionary Containers = new Dictionary { { "ActionSet", "actions"}, { "Container", "items" }, { "ColumnSet", "columns"}, { "Column", "items"}, { "FactSet", "facts"}, { "Fact", ""}, { "ImageSet", "images"} }; public static string strData = @" { ""template"" : { ""image"" : ""image"", ""clade"" : ""Clades"", ""name"" : ""Common Name"", ""order"" : ""Order"", ""family"" : ""Family"", ""genus"" : ""Genus"", ""species"" : ""Species (Latin Name)"" }, ""item"" : { ""image"" : ""almonds.jpg"", ""clade"" : [ ""Tracheophytes"", ""Angiosperms"", ""Eudicots"", ""Rosids"" ], ""name"" : ""American Hazelnut"", ""order"" : ""Fagales"", ""family"" : ""Betulaceae"", ""genus"" : ""Corylus"", ""species"" : ""Corylus Americana"" } } "; public static string strTemplate = @" { ""type"": ""AdaptiveCard"", ""body"": [ { ""type"": ""Container"", ""items"": [ { ""type"": ""TextBlock"", ""text"": ""{item.name}"", ""size"": ""Large"", ""weight"": ""Bolder"", ""horizontalAlignment"": ""Center"", ""color"": ""Accent"" }, { ""type"": ""Image"", ""url"": ""{item.image}"", ""altText"": """" }, { ""type"": ""ColumnSet"", ""columns"": [ { ""type"": ""Column"", ""width"": ""stretch"", ""horizontalAlignment"": ""Right"", ""items"": [ { ""type"": ""TextBlock"", ""text"": ""{template.other}"", ""weight"": ""Bolder"", ""horizontalAlignment"": ""Right"" } ] }, { ""type"": ""Column"", ""width"": ""stretch"", ""items"": [ { ""type"": ""TextBlock"", ""text"": ""{item.other}"" } ] } ] }, { ""type"": ""ColumnSet"", ""columns"": [ { ""type"": ""Column"", ""width"": ""stretch"", ""horizontalAlignment"": ""Right"", ""items"": [ { ""type"": ""TextBlock"", ""text"": ""{template.name}"", ""weight"": ""Bolder"", ""horizontalAlignment"": ""Right"" } ] }, { ""type"": ""Column"", ""width"": ""stretch"", ""items"": [ { ""type"": ""TextBlock"", ""text"": ""{item.name}"" } ] } ] }, { ""type"": ""ColumnSet"", ""columns"": [ { ""type"": ""Column"", ""width"": ""stretch"", ""horizontalAlignment"": ""Right"", ""items"": [ { ""type"": ""TextBlock"", ""text"": ""{template.order}"", ""weight"": ""Bolder"", ""horizontalAlignment"": ""Right"" } ] }, { ""type"": ""Column"", ""width"": ""stretch"", ""items"": [ { ""type"": ""TextBlock"", ""text"": ""{item.order}"" } ] } ] }, { ""type"": ""ColumnSet"", ""columns"": [ { ""type"": ""Column"", ""width"": ""stretch"", ""horizontalAlignment"": ""Right"", ""items"": [ { ""type"": ""TextBlock"", ""text"": ""{template.family}"", ""weight"": ""Bolder"", ""horizontalAlignment"": ""Right"" } ] }, { ""type"": ""Column"", ""width"": ""stretch"", ""items"": [ { ""type"": ""TextBlock"", ""text"": ""{item.genus}"" } ] } ] }, { ""type"": ""ColumnSet"", ""columns"": [ { ""type"": ""Column"", ""width"": ""stretch"", ""horizontalAlignment"": ""Right"", ""items"": [ { ""type"": ""TextBlock"", ""text"": ""{template.species}"", ""weight"": ""Bolder"", ""horizontalAlignment"": ""Right"" } ] }, { ""type"": ""Column"", ""width"": ""stretch"", ""items"": [ { ""type"": ""TextBlock"", ""text"": ""{item.species}"" } ] } ] }, { ""type"": ""ColumnSet"", ""columns"": [ { ""type"": ""Column"", ""width"": ""stretch"", ""horizontalAlignment"": ""Right"", ""items"": [ { ""type"": ""TextBlock"", ""text"": ""{template.clade}"", ""weight"": ""Bolder"", ""horizontalAlignment"": ""Right"" } ] }, { ""type"": ""Column"", ""width"": ""stretch"", ""items"": [ { ""type"": ""Container"", ""items"": [ { ""$data"": ""{item.clade}"", ""type"": ""TextBlock"", ""text"": ""{$data}"" } ] } ] } ] } ] } ], ""$schema"": ""http://adaptivecards.io/schemas/adaptive-card.json"", ""version"": ""1.0"" }"; }