I need your help to work miracles.
I want to convert Twig array to Javascript array and then use it in a loop and create markers for the Google API.
<script>
var map, marker, i, e;
var companies = {{ companies.items | json_encode() | raw }};
console.log(companies);
var address = {{ search.city.first.name | json_encode() | raw }};
function initMap() {
var geocoder = new google.maps.Geocoder();
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 44.8333, lng: -0.5667},
zoom: 12,
disableDefaultUI: true
});
//for (i = 0; i < locations.length; i++) {
//marker = new google.maps.Marker({
//position: new google.maps.LatLng(locations[i][1], locations[i][2]),
//map: map
//});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=APIKEYLOL&callback=initMap"></script>
When I get my array back, companies show me an empty array.

But when I dump this on twig my array is ok ..

Can someone help me?