[xwiki-users] Generating pure JSON with Velocity
17 Jan
2015
17 Jan
'15
6:12 a.m.
I'd like to be able to generate pure JSON from a wiki page, to use in other pages via AJAX. To that end I created a page with the following content: {{velocity wiki="false"}} $response.setContentType('application/json') { "greeting" : "Hello", "location": "World" } {{/velocity}} Calling this via /xwiki/bin/get/Sandbox/JsonTest I get the following code (as reported by FireBug): <p><br/>{<br/>"greeting" : "Hello",<br/>"location": "World"<br/>}</p> I get the same via /xwiki/bin/view/AlertDB/JsonTest?xpage=plain (as suggested in http://jira.xwiki.org/browse/XWIKI-3413). Is there a way to produce pure JSON by a velocity script by some variation of my approach?
4241
Age (days ago)
4241
Last active (days ago)
0 comments
1 participants
participants (1)
-
Bryn Jeffries