Search code examples
javagoogle-closure-templates

How to convert efficiently a Java object to SoyData in Google Closure


We have a Java object with data that we want to use for template rendering - is there an efficient way of converting Java object to SoyData?

Currently we are using gson to convert it to tree and recursively populate SoyData object, but maybe there is something that wouldn't require gson conversion.


Solution

  • So in the end I added a constraint that the data can be only in a form of a map and I was able to use a library object com.google.template.soy.data.SoyMapData to do the work.