In the last article, we explained how to create an ASP.NET Web API to merge templates with JSON data in the payload body of an HTTP request. The focus of this article was on the Web API and RESTful services itself.
Extracted from this project, this sample shows how to merge a template with a JSON string directly. The JSON data string has the following form:
It is the JSON representation of a flat XML file with nested data tables created with Newtonsoft.Json:
The following method accepts a template name and the JSON string as parameters. The JSON string is converted back to an XML file which is then converted to a DataSet object.
Finally, the document is merged by calling the Merge method. The resulting document is loaded into the ASP.NET DocumentViewer for visualization.
Download the sample from GitHub and test it on your own.
Download and Fork This Sample on GitHub
We proudly host our sample code on github.com/TextControl.
Please fork and contribute.
Requirements for This Sample
- Visual Studio 2012 or better
- TX Text Control .NET Server for ASP.NET (trial sufficient)