I am using a library handlebars.net. https://github.com/rexm/Handlebars.Net
Which takes a template string and an anonymous type and make the template filled with the anonymous type values. Here is an example:
string source =
@"<div class=""entry"">
<h1>{{title}}</h1>
<div class=""body"">
{{body}}
</div>
</div>";
var template = Handlebars.Compile(source);
var data = new {
title = "My new post",
body = "This is my first post!"
};
var result = template(data);
/* Would render:
<div class="entry">
<h1>My New Post</h1>
<div class="body">
This is my first post!
</div>
</div>
*/
In my case, I have a json file that I want to read from and use that as the anonymous type. If I use a json parser like newtonsoft, I get back a JSONObject type variable, and it works for basic values, but if I use arrays, it throws an exaction about not being able to convert a JArray to a String.
So my question is, is there a way to convert a json file into an anonymous type?
Thanks