Question 151
Open question ↗Scenario: Structured Data Extraction
An extraction service intermittently returns malformed JSON — missing braces and trailing commas — which breaks the downstream parser about 2% of the time. The team currently asks the model in the prompt to "return valid JSON only."
What is the most reliable way to eliminate these syntax errors?
- A.Strengthen the prompt wording and add "do not include markdown fences."
- B.Post-process the text with a regex that repairs braces and commas.
- C.Use `tool_use` with a JSON Schema so output is guaranteed syntactically valid and schema-conformant.
- D.Lower the temperature to 0 to avoid formatting mistakes.