using Newtonsoft.Json.Converters;
using System.Collections.Generic;
public static void Main()
var template = Template.Parse(@"
map creates an array of values by extracting the values of a named property from another object.
For this example assume site.pages is an array of content pages for a website, and some of these pages have an attribute called category that specifies their content category. If we map those categories to an array, some of the array items might be nil if any pages do not ave a category attribute.
{% assign site_categories = site.pages | map: ""category"" -%}
{% for category in site_categories -%}
{{ site.pages[0].category }}
{""category"": ""business""},
{""category"": ""celebrities""},
{ ""category"": ""lifestyle""},
{ ""category"": ""sports""},
{ ""category"": ""technology""}
var parsedJson = JsonConvert.DeserializeObject<ExpandoObject>(json, new ExpandoObjectConverter());
var hashFromDictionary = Hash.FromDictionary(parsedJson);
Console.Write(template.Render(hashFromDictionary));
Console.Write(hashFromDictionary.GetType());
Console.Write(hashFromDictionary["site"].GetType());
var hash = Hash.FromAnonymousObject(new
new { category = "business", author = "Joe" },
new { category = "celebrities", author = "Jon" },
new { category = "lifestyle", author = "John" },
new { category = "sports", author = "Joan" },
new { category = "technology", author = "Jean" }
Console.Write(template.Render(hash));
Console.Write(hash.GetType());
Console.Write(hash["site"].GetType());
var dictionary = new Dictionary<string, object>();
dictionary.Add("site", new Dictionary<string, object>());
(dictionary["site"] as Dictionary<string, object>).Add(
new Dictionary<string, string> { ["category"] = "business" },
new Dictionary<string, string> { ["category"] = "celebrities" },
new Dictionary<string, string> { ["category"] = "lifestyle" },
new Dictionary<string, string> { ["category"] = "sports" },
new Dictionary<string, string> { ["category"] = "technology" }
var hashFromNewDictionary = Hash.FromDictionary(dictionary);
Console.Write(template.Render(hashFromNewDictionary));
Console.Write(hashFromNewDictionary.GetType());
Console.Write(hashFromNewDictionary["site"].GetType());