{"id":"json-candidate-repair","version":"1.0.0","description":"Conservatively repair a JSON candidate (comments, trailing commas, truncation), log every edit and recheck RFC 8259.","supported_operations":["remove trailing commas from json","strip comments from jsonc before parsing","close truncated json from a cut off llm response","repair almost valid json conservatively","make model generated json parse without guessing","show exactly what was changed to fix my json"],"unsupported_operations":["quoting unquoted keys, converting single quotes, or replacing Python True/False/None","inventing missing values (a dangling key or colon stays invalid)","fixing mismatched brackets or reordering content","extracting JSON from surrounding prose (use json-candidate-list)"],"semantics":["rules (optional, default all three) selects from remove_comments, close_truncated, remove_trailing_commas; they always run in one left-to-right pass outside JSON strings regardless of array order. An empty array applies no repair and only validates.","remove_comments deletes '//' through the end of its line (the LF/CR is kept) and '/*' through the next '*/' (or the end of the text).","remove_trailing_commas deletes a ',' whose next significant character (skipping JSON whitespace and removed comments) is '}' or ']'. Only that last comma is deleted, so ',,]' stays invalid. With close_truncated it also deletes a ',' left dangling at the end of a truncated text.","close_truncated appends, at the end of the text, '\"' if the text ends inside a string, then the closer of every still-open bracket (innermost first). It is skipped when any closer did not match the innermost open bracket, when the text ends inside a string escape, or when nothing is open.","edits lists every change sorted by offset: {rule, offset (UTF-16 offset in the input), removed, inserted}. text is the result; changed is true when edits is non-empty. valid_json applies RFC 8259 strictly to text, and json_error is null or {code, offset} into text.","No value is ever invented: a text that is still invalid after these rules is returned with valid_json false (not an error)."],"limits":{"max_text_bytes":131072,"max_edits":512},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["text"],"properties":{"text":{"type":"string","maxLength":131072},"rules":{"type":"array","uniqueItems":true,"maxItems":3,"items":{"type":"string","enum":["remove_comments","close_truncated","remove_trailing_commas"]}}}},"output_schema":{"type":"object","additionalProperties":false,"required":["text","changed","valid_json","json_error","edits"],"properties":{"text":{"type":"string"},"changed":{"type":"boolean"},"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}}},"edits":{"type":"array","maxItems":512,"items":{"type":"object","additionalProperties":false,"required":["rule","offset","removed","inserted"],"properties":{"rule":{"type":"string","enum":["remove_comments","close_truncated","remove_trailing_commas"]},"offset":{"type":"integer","minimum":0},"removed":{"type":"string"},"inserted":{"type":"string"}}}}}},"examples":[{"input":{"text":"{\"a\": [1, 2,], // note\n \"b\": tru"},"output":{"text":"{\"a\": [1, 2], \n \"b\": tru}","changed":true,"valid_json":false,"json_error":{"code":"invalid_literal","offset":24},"edits":[{"rule":"remove_trailing_commas","offset":11,"removed":",","inserted":""},{"rule":"remove_comments","offset":15,"removed":"// note","inserted":""},{"rule":"close_truncated","offset":32,"removed":"","inserted":"}"}]}},{"input":{"text":"[{\"id\": 1}, {\"id\": 2"},"output":{"text":"[{\"id\": 1}, {\"id\": 2}]","changed":true,"valid_json":true,"json_error":null,"edits":[{"rule":"close_truncated","offset":20,"removed":"","inserted":"}]"}]}}],"execute_url":"/v1/tools/json-candidate-repair/versions/1.0.0/execute"}