Be careful that the Velocity code is executed on the server side,
before the JavaScript is evaluated by the browser. The following line
doesn't make any sense:
var test = $jsontool.parse('["json string"]')
'test' is a JavaScript variable while $jsontool.parse() returns a Java
object. 'test' is assigned on the client, in the browser, while
$jsontool.parse() is executed on the server. I don't see why you need
to parse JSON using Java when JSON means JavaScript Object Notation
and there are of course dedicated APIs to parse JSON into JavaScript
objects.
Hope this helps,
Marius
On Mon, May 26, 2014 at 9:34 PM, Danilo Amaral de Oliveira
<danilo.oliveira(a)energisa.com.br> wrote:
Hello Community,
Can I use velocity methods inside my JS code?
For example, I want to parse my JSON text to Java objects inside a JS function:
<js code>
Function function (){
Var test = $jsontool.parse('["json string"]')
}
Function();
</js code>
Is it possible?
Thanks
Danilo
Grupo Energisa
Danilo Oliveira
Analista Suporte Aplicacao TI - DPTO CORP. DE INFRAESTR. TI
e-mail: danilo.oliveira(a)energisa.com.br | tel: (32) 3429-6342 | cel: (32) 8452-9478
Esta mensagem contém informação confidencial. Se você a recebeu por engano, não divulgue
ou copie seu conteúdo. Por favor, avise ao remetente imediatamente e apague-a do
computador.
Privileged and confidential. If this message has been received by mistake, do not
disclose or copy its contents. Please notify sender and delete immediately.
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users