I'm trying to define a json object in the template with the JsValue of play (v2.2.2). The problem is, "
is converted to "
@(org: db.Tables.OrganizationRow)
@import models.format.EntityFormat._
@import play.api.libs.json.Json
<script type="text/javascript">
var org = @Json.toJson(org);
</script>
results in:
{"id":16,"userid":" ... more data ... };
How I'm able to get the correct json in the scala html template?
Define it as Html
so it doesn't automatically get escaped.
var org = @Html(Json.stringify(Json.toJson(org)));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With