renderJson


Description:

public static string renderJson (string template, JsonValue vars)

Renders a template using a JSON object as variables.

Top-level string values in the JSON object are extracted as template variables. Array values are joined with commas for use with the #each directive.

Example:

    var json = Json.parse ("{\"name\": \"World\"}");
string tpl = "Hi " + "{{na" + "me}}!";
string result = Template.renderJson (tpl, json);
// result == "Hi World!"

Parameters:

template

template string.

vars

JSON object containing variables.

Returns:

rendered string.