title: Passing JSON string to JavaScript
body: <p>I'm working on a project, and we use a lot of coding languages for different parts.</p>
  
  <p>I've tried to simplify the problem as much as I can, and came up with the following
  <a href="http://jsfiddle.net/v0x9p6d7/6/" rel="nofollow noreferrer">JSfiddle</a>.</p>
  
  <p>The problem is, I have a JSON string which I want to pass on to a JavaScript function.
  If I call it from JavaScript, it's OK. But when I call it with a <code>onmouseover</code>, HTML throws the error</p>
  
  <blockquote>
    <p>Uncaught SyntaxError: Invalid or unexpected token</p>
  </blockquote>
  
  <h3>JavaScript Code:</h3>
  
  <pre class="lang-js prettyprint-override"><code> function test123(obj, e, lookupx){
        console.log(lookupx);
      }
  
      test123(this, event, '{"mt:assetsys:assetuapr":{"assetmat":"material","assettag":"tag"}}');
  </code></pre>
  
  <h3>HTML:</h3>
  
  <pre class="lang-html prettyprint-override"><code>    &lt;div&gt;
        First check the console, direct calling with js string is ok.&lt;br&gt;
        Then:&lt;br&gt;
        &lt;a href="#" onmouseover="test123(this, event, '{"mt:assetsys:assetuapr": 
                   {"assetmat":"material","assettag":"tag"}}');"&gt;hover this
        &lt;/a&gt;
        &lt;br&gt;
        And an error occurs
      &lt;/div&gt;
  </code></pre>
  
  
  
  <p>Could someone explain what the difference is between the two cases?</p>
  
  <ol>
  <li><p>The onmouseover <strong>vs</strong></p></li>
  <li><p>The direct calling to the function.</p></li>
  </ol>