Passing a code in JSON format

I am building an app where the user submits a piece of code and chatgpt verifies it for errors. Every time I pass the code into the gpt conversation, I get a JSON error. I tried using the format as JSON safe option before sending the code in but I still get the same error. I tried replace all special characters using the find &replace but I still end up getting the same error.

Has anyone had similar issue before and solved it? I spent the whole day today on this issue and still unable to resolve it.

Anyone?

Hi! Can you share the screenshot of your setup with the :formatted as JSON-safe operator?

So what I am doing is, I am using a code editor and saving the code in the db formatted as JSON safe. Then I am passing the code into a state where I remove the quotation or speech marks. This is then sent as a input to GPT.


Can you share your GPT call too? Ideally, if you’re using :formatted as JSON safe, you don’t need to add quotes around the value. This is something I had missed and realised sometime back, so it might be worth checking at your end

The find & replace in the first screenshot is the remove the quotation marks.