static void Main(string[] args) { var template = string.Join("", File.ReadAllLines("template.txt")); var test = new Test { Key = "keyValue", Name = "nameValue", Code = "codeValue", Related = new Test { Key = "childKeyValue", Name = "childNameValue", Code = "childCodeValue" } }; var result = JsonTemplateVisitor.Serialize(test, template); }
public static JToken Serialize(object data, JToken template) { var visitor = new JsonTemplateVisitor(data); return(visitor.Visit(template)); }