Convert "['a','b','c']" to ['a','b','c'] : Javascript
<p>Which would be best way to do these things?</p>

<p><strong>Note:</strong> My array contains complex values means comma separated or object values in side string array  &amp; Arrays string quoted in <strong>double</strong> quotes and elements are in <strong>single</strong> quotes.</p>

<p><strong>EX.</strong> <code>str = "['sam', 'admin', '1062', 'Sam', 'True', '$$global_permissions#1062:manage_replenishment,purchase_order,reprint_invoice#1008', 'sameer@opnce.com', '9920580', 'en', '358', '{\"Sales-tax-details\":\"brand,category,supplierNo\",\"invoice-logs\":\"invoiceNo,eventDateTime,event\"}']"</code></p>

<p>Here i played with <code>JSON.parse</code>, </p>

<pre><code>JSON.parse(str);
Uncaught SyntaxError: Unexpected token ' // this error i got on console
</code></pre>

<p>Then i tried,</p>

<pre><code>JSON.parse(str.replace(/'/g, '"'))
Uncaught SyntaxError: Unexpected token S  // this error i got on console
</code></pre>

<p>One more thing i wanted to explore here as,
if <code>str</code> contains following elements,</p>

<p><code>str = "['sam', 'admin', '1062', 'Sam', 'True', '$$global_permissions#1062:manage_replenishment,purchase_order,reprint_invoice#1008', 'sameer@opnce.com', '9920580', 'en', '358', '{}']"</code></p>

<p>for this <code>str</code> i tried,</p>

<pre><code>JSON.parse(str.replace(/'/g, '"'))
</code></pre>

<p>Its working fine here,</p>

<p>Regards.</p>
