{"slug": "your-llm-returned-valid-json-can-your-app-trust-it", "title": "Your LLM Returned Valid JSON. Can Your App Trust It?", "summary": "A developer outlined a three-layer approach to validating LLM structured output, arguing that JSON parsing and schema checks are insufficient to guarantee correctness. Using a support-assistant example, the developer showed that a syntactically valid refund request can still misread a customer asking for a replacement, and recommended treating model output as a proposed interpretation that backend logic must verify against order ownership, eligibility and intent. The developer also suggested giving models an explicit \"needs_clarification\" state so ambiguous requests trigger follow-up questions rather than forced guesses.", "body_md": "Getting an LLM to return valid JSON feels like a milestone. The response parses, the fields exist, and the application can finally do something with the output.\n\nBut there’s another question: are those fields actually correct?\n\nConsider a support assistant that turns a customer’s message into a structured request:\n\n```\n{\n  \"order_id\": \"ORD-1042\",\n  \"action\": \"refund\",\n  \"reason\": \"damaged_item\"\n}\n```\n\nEverything looks reasonable. Yet the customer might have written: “My item arrived damaged. Can I get a replacement? I don’t want a refund.”\n\nThe JSON is valid. The action is wrong.\n\n**1. Can the application parse it?**\n\nThis is the syntax check. Is the response valid JSON, or did it include extra text, broken quotes, or an incomplete object?\n\n**2. Does it match the expected structure?**\n\nThis is the schema check. Are the required fields present? Are values the right types? Is `action` one of the allowed options?\n\nA schema can reject an unknown action. It cannot, by itself, determine whether an allowed action matches the customer’s intent.\n\n**3. Is the result supported and permitted?**\n\nThis is where application logic matters. Does the order belong to the authenticated customer? Did the customer request this action? Is the order eligible? Does the operation require confirmation?\n\nThese checks need information beyond the shape of the model’s response.\n\nFor a workflow like this, I’d treat the model’s output as a proposed interpretation. The backend would check the order, apply the relevant rules, and ask for clarification when the request is ambiguous.\n\nIt also helps to give the model a way to express missing information. A required field with no “unknown” option creates pressure to fill in something, even when the source doesn’t support a confident answer.\n\nFor example, an incomplete request could go into a `needs_clarification` state instead of being forced into `refund` or `replacement`.\n\nThat state should have a real application path: ask a follow-up question, preserve the existing information, and wait before taking action.\n\nTry evaluating the same workflow with:\n\nCheck both the extracted fields and what the application does next. A response can pass every formatting check and still lead to the wrong operation.\n\nStructured output makes model responses easier to process. Deciding when to trust those responses remains part of the application’s design.\n\n**Have you encountered an LLM response that passed validation but was still wrong in a way that mattered? How did you catch it?**", "url": "https://wpnews.pro/news/your-llm-returned-valid-json-can-your-app-trust-it", "canonical_source": "https://dev.to/4sapi/your-llm-returned-valid-json-can-your-app-trust-it-5h6i", "published_at": "2026-10-27 02:28:44+00:00", "updated_at": "2026-10-27 02:41:51.799921+00:00", "lang": "en", "topics": ["large-language-models", "ai-agents", "ai-tools", "developer-tools"], "entities": [], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/your-llm-returned-valid-json-can-your-app-trust-it", "markdown": "https://wpnews.pro/news/your-llm-returned-valid-json-can-your-app-trust-it.md", "text": "https://wpnews.pro/news/your-llm-returned-valid-json-can-your-app-trust-it.txt", "jsonld": "https://wpnews.pro/news/your-llm-returned-valid-json-can-your-app-trust-it.jsonld"}}