function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SImmySImmy 

How to replace single quotes with double quotes in JSON. Please help

[{'InvoiceNumber':'DRAFT-0000007','ErrorDescription':'2130701-Customer Account Number doesn't exist in SAGE metadata'},{'InvoiceNumber':'DRAFT-0000166','ErrorDescription':'1778001-Customer Account Number doesn't exist in SAGE metadata'},{'InvoiceNumber':'DRAFT-0000000','ErrorDescription':'2281401-Customer Account Number doesn't exist in SAGE metadata'}]
AnudeepAnudeep (Salesforce Developers) 
Hi Slmmy, 

You can try using .replace to replace single quotes with double quotes while parsing JSON

Here is an example:

If "captcha_settings" is using single quotes, we replace the single quote with a double quote by adding .replace as follows

JSON.parse(document.getElementsByName("captcha_settings")[0].value.replace(/'/g, '"'));

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thank you
SImmySImmy
Hi Anudeep, I've resolved the issue few days back by simply converting into string and then replacing all the characters with double quotes.. and again checking if there are any word which is getting converted to double quotes as well like if it contains (doesn't =doesn"t) then I'm again replacing only those which is n"t.. and it's working fine.