banduk
banduk

Reputation: 107

How to convert List<Object> to JSON on playframework Java

First of all, I am using playframework 2 with Java.

I have a Bootstrap-lookahead input field in a view and I want to use a json array as source for it, as described here. I can generate json at server-side with:

Json.toJson(users)

or on client with:

@{Json.toJson(users)}

However it generates strings with " and when I try to create the bootstrap-lookahead field with this data, it gives me

Uncaught SyntaxError: Unexpected token &

Could someone help me with that?

Thank you

Upvotes: 3

Views: 2611

Answers (1)

Infinity
Infinity

Reputation: 3441

You can prevent escaping by using @Html(Json.toJson(users)) in template.

Docs, last paragraph

Upvotes: 4

Related Questions