I've found this library to be quite good at fixing JSON returned by an LLM: https://github.com/mangiucugna/json_repair
It's much quicker than prompting an LLM, and I haven't found anything it was unable to fix. Just a suggestion, but wanted to point this out for performance reason.