Search code examples
javajsonrestognl

JSONObject serialization using template


i have to build a text from a JSONObject and a Template up. The template seems like this:

"Hi ${user.name} ${user.surname}, 

greetings from ${sender.name} with "${message}"

The template is not static. i mean, the client can send any type of Entities (from which the JSONObject is unmarshalled) and suitable templates for these.

I would use OGNL on JSONObject navigating over object graph. But are there any other solutions like XSTL for Json? other something like this ?


Solution

  • If you can live with a slightly different syntax for the template, perhaps mustache would do it. It is available for multiple languages, including Java and JavaScript. -> http://mustache.github.com/