Hi all, I'd like to commit a new velocity tool to help producing JSON from velocity. It's mainly a wrapper around the json-lib library (http://json-lib.sourceforge.net/).
For a first version, I propose the 2 following APIs : public JSON toJSON(Object object) public String toValueString(String value) The first one should become a privileged way of producing JSON from velocity. It allows to easily write a JSON-valid String from java beans and/or maps. See http://json-lib.sourceforge.net/usage.html#objects for more information of what it makes possible. Note that JSON#toString actually writes down the valid JSON, so in velocity we just have to do : $jsontool.toJSON($object) The second API is a helper to produce a JSON-valid value String from a java String (it escapes properly quotes). I've pasted the proposed implementation at http://incubator.myxwiki.org/xwiki/bin/view/Main/VelocityJsonToolProposal As a bonus, this will make the JSON groovy builder (http://json-lib.sourceforge.net/apidocs/jdk15/net/sf/json/groovy/JsonGroovyBuilder.html) and the JSONSlurper (http://json-lib.sourceforge.net/apidocs/jdk15/net/sf/json/groovy/JsonSlurper.html) available for groovy scripting. If you agree I would like to commit it in branch 2.0 as well, as this is the clean way of fixing some issues with the livetable. (For example : http://jira.xwiki.org/jira/browse/XWIKI-4282). My +1 for the tool, Thanks, Jerome. _______________________________________________ devs mailing list devs@xwiki.org http://lists.xwiki.org/mailman/listinfo/devs