{"id":"json-candidate-list","version":"1.0.0","description":"Find and rank JSON object/array candidates in prose and Markdown fences (quotes and lists too) with exact raw spans.","supported_operations":["find json objects embedded in an llm answer","pick the best json candidate from model output","locate json snippets in markdown and prose with offsets","rank possible json payloads in a chat reply","which part of this text is the json","find truncated json in a response","scan text for curly brace or square bracket json blocks"],"unsupported_operations":["returning scalar JSON values (strings, numbers, true/false/null) as candidates","scanning code fences tagged with a non-JSON language such as python","guessing intent or semantic correctness of the JSON (only syntax validity is checked)","non-conservative repairs such as quoting keys or converting single quotes"],"semantics":["The text is parsed as CommonMark 0.31.2 blocks (same rules as json-fence-extract). Scanned regions: fenced code whose language is json/jsonc/json5 (source json_fence), fenced code without a language (untagged_fence), indented code (indented_code), and paragraphs, headings and HTML blocks (prose). Fences with any other language are skipped. Each region is its leaf text with container markers (block quote markers, list item indentation) removed and lines joined by \\n.","Within a region, a single left-to-right pass starts a candidate at each '{' or '[' not already consumed and matches brackets with JSON string awareness. It is complete when the first bracket closes. It is incomplete with incomplete_reason mismatched_closer (a closer that does not match), unterminated_string (a line ends inside a string, or the text ends inside one) or unclosed (the text ends); incomplete text drops trailing JSON whitespace. Scanning resumes after the candidate, after the mismatched closer or after the line ending.","start and end are raw UTF-16 offsets in the input of the first and one-past-last character of text; start_line and end_line are 1-based. contiguous is true when the raw slice [start, end) equals text (false when container markers or indentation were removed inside it).","valid_json applies RFC 8259 strictly to text; json_error is null or {code, offset} into text. repair (optional, default false) adds a repair object per candidate: all three json-candidate-repair rules applied to text, with the repaired text, its RFC 8259 validity and the rules that changed it; otherwise repair is null.","Ranking (fixed, total): tier 0 valid_json, tier 1 valid only after repair (repair true), tier 2 the rest; then source json_fence, untagged_fence, indented_code, prose; then complete before incomplete; then longer text (UTF-16 units) first; then smaller start first. rank is 1-based.","max_results (optional, default 10, 1 to 100) caps the returned candidates; candidate_count is the number found and truncated is true when candidates were cut."],"limits":{"max_text_bytes":131072,"max_results":100,"max_container_depth":64},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["text"],"properties":{"text":{"type":"string","maxLength":131072},"repair":{"type":"boolean"},"max_results":{"type":"integer","minimum":1,"maximum":100}}},"output_schema":{"type":"object","additionalProperties":false,"required":["candidates","candidate_count","truncated"],"properties":{"candidate_count":{"type":"integer","minimum":0},"truncated":{"type":"boolean"},"candidates":{"type":"array","maxItems":100,"items":{"type":"object","additionalProperties":false,"required":["rank","source","fence_index","start","end","start_line","end_line","text","contiguous","top_level","complete","incomplete_reason","valid_json","json_error","repair"],"properties":{"rank":{"type":"integer","minimum":1},"source":{"type":"string","enum":["json_fence","untagged_fence","indented_code","prose"]},"fence_index":{"type":["integer","null"],"minimum":0},"start":{"type":"integer","minimum":0},"end":{"type":"integer","minimum":0},"start_line":{"type":"integer","minimum":1},"end_line":{"type":"integer","minimum":1},"text":{"type":"string","minLength":1},"contiguous":{"type":"boolean"},"top_level":{"type":"string","enum":["object","array"]},"complete":{"type":"boolean"},"incomplete_reason":{"type":["string","null"],"enum":["mismatched_closer","unterminated_string","unclosed",null]},"valid_json":{"type":"boolean"},"json_error":{"type":["object","null"],"additionalProperties":false,"required":["code","offset"],"properties":{"code":{"type":"string","enum":["unexpected_end","unexpected_character","trailing_content","invalid_escape","control_character_in_string","invalid_number","invalid_literal"]},"offset":{"type":"integer","minimum":0}}},"repair":{"type":["object","null"],"additionalProperties":false,"required":["text","valid_json","json_error","rules_applied"],"properties":{"text":{"type":"string"},"valid_json":{"type":"boolean"},"json_error":{"type":["object","null"],"additionalProperties":false,"required":["code","offset"],"properties":{"code":{"type":"string","enum":["unexpected_end","unexpected_character","trailing_content","invalid_escape","control_character_in_string","invalid_number","invalid_literal"]},"offset":{"type":"integer","minimum":0}}},"rules_applied":{"type":"array","maxItems":3,"uniqueItems":true,"items":{"type":"string","enum":["remove_comments","close_truncated","remove_trailing_commas"]}}}}}}}}},"examples":[{"input":{"text":"Sure! {\"a\": 1} is what you need."},"output":{"candidates":[{"rank":1,"source":"prose","fence_index":null,"start":6,"end":14,"start_line":1,"end_line":1,"text":"{\"a\": 1}","contiguous":true,"top_level":"object","complete":true,"incomplete_reason":null,"valid_json":true,"json_error":null,"repair":null}],"candidate_count":1,"truncated":false}},{"input":{"text":"> ```json\n> {\"ids\": [1,\n>   2,]}\n> ```\n","repair":true},"output":{"candidates":[{"rank":1,"source":"json_fence","fence_index":0,"start":12,"end":32,"start_line":2,"end_line":3,"text":"{\"ids\": [1,\n  2,]}","contiguous":false,"top_level":"object","complete":true,"incomplete_reason":null,"valid_json":false,"json_error":{"code":"unexpected_character","offset":16},"repair":{"text":"{\"ids\": [1,\n  2]}","valid_json":true,"json_error":null,"rules_applied":["remove_trailing_commas"]}}],"candidate_count":1,"truncated":false}}],"execute_url":"/v1/tools/json-candidate-list/versions/1.0.0/execute"}