How to attach JSON data to JS variable without it being escaped I'm having so much trouble with drupal 8 right now.

when in Drupal 7 I could do:

drupal_add_js("var a = 'b';");


and be done with it, for the life of my, I can't figure out how to attach data to a JS variable in Drupal 8

I had to write a custom THEME_preprocess_page function to add the JSON value to drupalSettings like this:

$variables['page']['content']['#attached']['drupalSettings']['customPricelist'] = $result;


but in reality the result get's escaped with quotation marks like:

"{"some":"stuff"}"


and is not usable..

Any ideas?
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'
  ];
}