Hey guys I’m trying to parse a JSON output from Claude API and I suspect because of the typographical and punctuation symbols within its output, it’s disrupting the JSON structure and therefore my next module which is ‘parse JSON’ keeps saying that ‘source is not valid JSON’. Is there any work around I can use for this or any smart strategies. Please see pic attach
If your AI model output format is always the same and validated then this error has not come.
This is a very common error that occurs with most users who don’t know more about how the prompt, json and any of the AI module settings work.
Just keep in mind that whatever AI Model you’re using it always needs 3 things in the prompt.
→ Input( Explain to them the background and whether this is my sample data or actual data).
→ Process ( What is the process you need to do on that data? Like transform, translate, combine etc)
→ Output (In a prompt also tell them that this is my sample output and I also want that generated output will be given in this specific format).
Also, read my given answer on this topic. Not the same but at least you can understand the concern that I’m trying to explain.
P.S.: Always search first, Check Make Academy. If this is helpful, Mark Best Answers as Solutions and give If you need expert help or have questions? Contact or comment below!
Yup, that’s definitely invalid JSON because there are newlines in the post strings.
I guess you’ll have to use a smarter AI model, improve your prompt, or switch to another AI service that can output correct JSON directly like OpenAI or Groq.
Hope this helps! Let me know if there are any further questions or issues.