How to attach JSON data to JS variable without it being escaped
something like:

$variables['page']['content']['#attached']['html_head'][] = [
    // The data.
    [
      '#type' =&gt; 'html_tag',
      // The HTML tag to add, in this case a  tag.
      '#tag' =&gt; 'script',
      // The value of the HTML tag, here we want to end up with alert("Hello world!");.
       '#value' =&gt; 'alert("Hello world!");',
       // set attributes like src to load a file
       '#attributes' =&gt; array('src' =&gt; ''),

    ],
    // A key, to make it possible to recognize this HTML  element when altering.
    'hello-world'
  ];
}