You shouldn't need to convert it to a json string. You could return a typesafe object and Stapler will take care of converting it to json for you. Then it could be used by the "backend code" as well in the future.