Hi Bryn,
On 19 Jan 2015 at 02:41:00, Bryn Jeffries
(bryn.jeffries@sydney.edu.au(mailto:bryn.jeffries@sydney.edu.au)) wrote:
Thanks so much for that. It did indeed work :-)
So 'view' with xpage=plain&outputSyntax=plain or just 'get' with
outputSyntax=plain does the job.
Now I know what to look for, for posterity I've put this information into
http://extensions.xwiki.org/xwiki/bin/view/Extension/Output+JSON
cool thanks!
FWIW I'd have rather put the license as something
like "public domain", but the closest ("Do What The F*** You Want..")
seemed unnecessarily vulgar. Does such language really have a place on your website?
I agree it looks vulgar. However this is a real license,
see
http://www.wtfpl.net/about/ and
http://en.wikipedia.org/wiki/WTFPL
Thanks
-Vincent
Thanks,
Bryn
From: Vincent Massol [vmassol(a)gmail.com] on behalf of vincent(a)massol.net
[vincent(a)massol.net]
Sent: 17 January 2015 21:23
To: XWiki Users
Cc: Bryn Jeffries
Subject: Re: [xwiki-users] Generating pure JSON
Hi Bryn,
On 17 Jan 2015 at 09:43:30, Bryn Jeffries
(bryn.jeffries@sydney.edu.au(mailto:bryn.jeffries@sydney.edu.au)) wrote:
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:
{
"greeting" : "Hello",
"location": "World"
}
I get the same via /xwiki/bin/view/AlertDB/JsonTest?xpage=plain.
If I remove the $response.setContentType('application/json')
https://dev.alertnessdb.net/xwiki/bin/view/AlertDB/JsonTest?xpage=plain
Inded, I would have imagine also that xpage=plain would have worked but it doesn’t. You
have to use outputsyntax.
For example:
http://playground.xwiki.org/xwiki/bin/get/Main/VMA?outputSyntax=plain
Note: You can go on a page with a livetable and check with Chrome dev tools or Firebug
the requests done and you’ll see it uses that.
Thanks
-Vincent