Hi everybody,

I am new at XWiki and I would like to know if it's possible to build a JSON object in a velocity script and get later this JSON via the REST API.

This is my script :

{{velocity}}

#if($xcontext.action == 'get' && "$!{request.outputSyntax}" == 'plain')
 $response.setContentType('application/json')
#end

#set($hql = "")
#set($results = $xwiki.searchDocuments($hql))
#set($json= "[" )
#set($started = false)
#foreach($item in $results)
 #set($itemdoc = $xwiki.getDocument($item))
 #if($started)
   #set($pointvirgule=",")
   #set($json = "${json} ${pointvirgule}" )
 #else
   #set($started = true)
 #end

#set($suite="{ ""name"" : ""${itemdoc.fullName}""}")
#set($json= "${json} ${suite}")

#end

#set($fin="]")
#set($json= "${json} ${fin}")

$json


{{/velocity}}

I thought my JSON would be in the content of my page but when I try to get this content with REST API I only have the velocity script in hard.


Someone could help me ?

Thanks in advance for your answers.

Pierrick

_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to