title: "SyntaxError: expected property name, got '&'" when passing JSON.stringify()ed array to Express template using Node.js
body: <p>I am trying to pass a JSON array formed on the backend using node.js to a frontend template so that it can be manipulated by a user. However, I'm having some trouble doing this. Here's the code I am using to render the page:</p>
  
  <pre><code>res.render('pages/profile.ejs', {
                  user : doc // get the user out of session and pass to template
                  ,passArray: JSON.stringify(passArray)
              });
  </code></pre>
  
  <p>Then in the scripts for the profile on the frontend I have: </p>
  
  <pre><code>&lt;script&gt;
          var passArrayFull= &lt;%=passArray%&gt;];  
          //do stuff with passArrayFull
          console.log(passArrayFull);
  &lt;/script&gt;
  </code></pre>
  
  <p>The problem is that I get that SyntaxError from the frontend site, and when I look at the source to inspect passArray it looks like this:</p>
  
  <pre><code>[{&amp;#34;unit&amp;#34;:&amp;#34;B1&amp;#34;,&amp;#34;name&amp;#34;: 
  </code></pre>
  
  <p>(etc)</p>
  
  <p>So it looks like somehow the JSON.stringify is converting the " character to the HTML entity &amp;#34 and it's not converting back, even if I wrap the frontend in JSON.parse(). I tried not using JSON.stringify, but then it seems like the full array can't be passed (I get a different error). What am I doing wrong here?</p>