title: Velocity Template Not working
body: <p>I am trying to parse a json using velocity template. Here is my json string, </p>
  
  <pre><code>{\n  \"firstName\": \"Tom\",\n  \"lastName\": \"Geller\",\n  \"department\": \"Retail\",\n  \"manager\": \"Steve\",\n  \"joiningDate\": \"03/08/2011\",\n  \"employees\": [\n    {\n      \"firstName\": \"Paul\",\n      \"lastName\": \"Balmer\",\n      \"department\": \"Retail\",\n      \"manager\": \"Tom Geller\",\n      \"joiningDate\": \"06/21/2014\"\n    },\n    {\n      \"firstName\": \"Eric\",\n      \"lastName\": \"S\",\n      \"department\": \"Retail\",\n      \"manager\": \"Tom Geller\",\n      \"joiningDate\": \"09/13/2014\"\n    }\n  ]\n}
  </code></pre>
  
  <p>This is my velocity template, </p>
  
  <pre><code>$firstName $lastName belongs to $department Department. 
  His manager is $manager and joining date is $joiningDate.
  
  Employees reporting to him are, 
  #foreach( $employee in $employees )
      $employee.firstName $employee.lastName
  #end
  </code></pre>
  
  <p>This is the output that gets printed. It doesn't print the reporting employees, </p>
  
  <pre><code>Tom Geller belongs to Retail Department. 
  His manager is Steve and joining date is 03/08/2011.
  
  Employees reporting to him are, 
  </code></pre>
  
  <p>Here is the java code, </p>
  
  <pre><code>public class VelocityTemplateDemo {
  
  protected VelocityEngine velocity;
  
  public VelocityTemplateDemo() {
      velocity = new VelocityEngine();
      velocity.init();
  }
  
  public String publish(String templatePath, String jsonString) throws IOException {
      JSONObject jsonObj = new JSONObject(jsonString);
      VelocityContext context = new VelocityContext();
      for (Object key : jsonObj.keySet()) {
          String keyString = String.valueOf(key);
          context.put(keyString, jsonObj.get(keyString));
      }
      Writer writer = new StringWriter();
      velocity.mergeTemplate(templatePath, "UTF-8", context, writer);
      writer.flush();
      return writer.toString();
  }
  
  public static void main(String[] args) throws IOException {
      String str = "{\n  \"firstName\": \"Tom\",\n  \"lastName\": \"Geller\",\n  \"department\": \"Retail\",\n  \"manager\": \"Steve\",\n  \"joiningDate\": \"03/08/2011\",\n  \"employees\": [\n    {\n      \"firstName\": \"Paul\",\n      \"lastName\": \"Balmer\",\n      \"department\": \"Retail\",\n      \"manager\": \"Tom Geller\",\n      \"joiningDate\": \"06/21/2014\"\n    },\n    {\n      \"firstName\": \"Eric\",\n      \"lastName\": \"S\",\n      \"department\": \"Retail\",\n      \"manager\": \"Tom Geller\",\n      \"joiningDate\": \"09/13/2014\"\n    }\n  ]\n}";
      String result = new VelocityTemplateDemo().publish("/src/main/resources/template.vm", str);
      System.out.println(result);
  }
  
  }
  </code></pre>