I have a list of objects, of which I only need each object's ID (of type String) property.
In the view, I have Google Tag Manager set up and need to pass the IDs of each object as a JSON array. I'm not sure how to do this in Twirl because I'm working with a Scala object inside a script tag. I need each string to quotation marks around it, separated by commas, and have brackets on each side like ["one","two","three"]. Is there any way to do this?
The permissions value is what's giving me trouble:
@()(implicit currentUser: User = new User())
<script>
dataLayer = [{
'userId': '@currentUser.userId',
'firstName': '@currentUser.firstName',
'lastName': '@currentUser.lastName',
'permissions': ['@currentUser.permissions.map(p => p.permissionId).mkString(",")']
}];
</script>