Issues in JSON Mode in JavaScript

What’s the right way to convert the JSON returned in the form of a string, into a normal JSON, for some reason getting alot of issues. Following is what I am trying.

const response = response.replace(/'/g, ‘"’).replace(/(\w+):/g, ‘“$1”:’);
const data = JSON.parse(formattedContent);

JSON IS a string.

Perhaps you mean to parse it out and set variables and data objects in your code from an API return object.

You should be able to use any JSON library to operate on the string from an API, or the network request library itself may have a .json() method to create programming language data equivalent.

You may simply have two layers of JSON to properly parse if you are talking about OpenAI API tool return arguments, where the inner JSON has escaped characters.