I am using mustache.java and wish to plug the json string instead of an object. I am not sure why no one faced this issue before.
// works since an 'Example' object is passed in
mustache.execute(new BufferedWriter(new FileWriter(objFile)), new Example()).flush();
// does not work since a json object is passed in directly
JSONObject jsonObject = new JSONObject("{\n" +
" \"header\": \"Colors\",\n" +
" \"items\": [\n" +
" {\"name\": \"red\", \"first\": true, \"url\": \"#Red\"},\n" +
" {\"name\": \"green\", \"link\": true, \"url\": \"#Green\"},\n" +
" {\"name\": \"blue\", \"link\": true, \"url\": \"#Blue\"}\n" +
" ],\n" +
" \"empty\": false\n" +
"}");
mustache.execute(new BufferedWriter(new FileWriter(objFile)), jsonObject).flush();