title: How to pass a JSON object in javascript function as a function parameter?
body: <p>In my js function,I create <code>a div and a link</code> ,when click the link,I will pass a parameter the another js funcion?What's wrong with my code?</p>
  
  <p><strong>js function1</strong> </p>
  
  <pre><code> //pass a json:the browser show wrong:SyntaxError: missing ] after element list
   //passJson([object Object])
   var dataItem=getDataItem();//a json object which has title and name property
   var divStr="&lt;div&gt;&lt;a style='cursor: pointer' onclick='passJson(" + dataItem +")'&gt;&lt;span title='spantitle'&gt;&lt;i class='icon-mouse'&gt;&lt;/i&gt;&lt;/span&gt;&lt;/a&gt;;&lt;/div&gt;";
  </code></pre>
  
  <p>So I try to add the "[]" to the function,but it still show wrong.</p>
  
  <p><strong>js function2</strong> </p>
  
  <pre><code> //pass a json:the browser show wrong:SyntaxError: missing ] after element list
   //passJson([object Object])
   var dataItem=getDataItem();// a json object which has title and name property
   var divStr="&lt;div&gt;&lt;a style='cursor: pointer' onclick='passJson([" + dataItem +"])'&gt;&lt;span title='spantitle' &gt;&lt;i class='icon-mouse'&gt;&lt;/i&gt;&lt;/span&gt;&lt;/a&gt;;&lt;/div&gt;";
  </code></pre>