{"record":{"id":"d4d9b20c17b85733","repo":"can1357/oh-my-pi","slug":"expected-in-object","errorCode":null,"errorMessage":"Expected ':' in object","messagePattern":"Expected ':' in object","errorType":"exception","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/json-parse.ts","lineNumber":278,"sourceCode":"\t\t\t}\n\t\t\tconst c = this.#s[this.#i];\n\t\t\tif (c === \"}\") {\n\t\t\t\tthis.#i++;\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\tif (c === \",\") {\n\t\t\t\t// Tolerate leading / doubled / trailing commas.\n\t\t\t\tthis.#i++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst key = this.#key();\n\t\t\tthis.#ws();\n\t\t\tif (this.#i < this.#n && this.#s[this.#i] === \":\") {\n\t\t\t\tthis.#i++;\n\t\t\t} else if (this.#partial) {\n\t\t\t\treturn out;\n\t\t\t} else {\n\t\t\t\tthrow new SyntaxError(\"Expected ':' in object\");\n\t\t\t}\n\t\t\tthis.#ws();\n\t\t\tif (this.#i >= this.#n) {\n\t\t\t\tif (this.#partial) return out;\n\t\t\t\tthrow new SyntaxError(\"Expected value after ':'\");\n\t\t\t}\n\t\t\tconst value = this.#value(true);\n\t\t\tif (value === INCOMPLETE) return out;\n\t\t\tout[key] = value;\n\t\t\tthis.#ws();\n\t\t\tconst d = this.#i < this.#n ? this.#s[this.#i] : \"\";\n\t\t\tif (d === \",\") {\n\t\t\t\tthis.#i++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (d === \"}\") {\n\t\t\t\tthis.#i++;\n\t\t\t\treturn out;","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/json-parse.ts#L260-L296","documentation":"Thrown by RelaxedJson.#object in strict mode after parsing an object key when the next character is not ':' and end-of-input was not reached. Even this relaxed parser requires a colon between key and value; in partial mode it bails out with the object parsed so far instead of throwing.","triggerScenarios":"parseJsonWithRepair with '{\"a\" 1}', '{a; b}', or a key followed directly by another key '{\"a\" \"b\": 1}' — i.e. a missing or malformed ':' separator in strict mode.","commonSituations":"Hand-written or template-generated JSON missing the colon; an LLM emitting YAML-ish 'key value' pairs instead of JSON; a copy/paste that dropped the ':' character.","solutions":["Fix the input so every key is followed by ':' before its value","Use parseStreamingJson if the input may be an incomplete prefix (it returns the partial object instead of throwing)","Run repairJson first if raw control characters or bad escapes are corrupting the structure (a bad escape can make the parser misjudge key boundaries)","Log the raw input around the failing key and regenerate the JSON from the producing system"],"exampleFix":"// before\nconst v = parseJsonWithRepair(`{\"a\" 1}`); // SyntaxError: Expected ':' in object\n// after\nconst v = parseJsonWithRepair(`{\"a\": 1}`); // {a: 1}","handlingStrategy":"validation","validationCode":"// Sanity-check object structure before parsing: every key must be followed by ':'\nconst ok = /^\\s*\\{.*\\}\\s*$/s.test(text) && !/['\"]?\\w+['\"]?\\s+[^:,}\\s]/.test(text.replace(/\"(\\\\.|[^\"\\\\])*\"/g, '\"S\"'));","typeGuard":null,"tryCatchPattern":"try {\n  const value = parseJsonWithRepair<T>(text);\n} catch (err) {\n  if (err instanceof SyntaxError && err.message === \"Expected ':' in object\") {\n    // reject or regenerate the malformed payload; log the raw text for diagnosis\n  } else throw err;\n}","preventionTips":["Generate JSON with JSON.stringify, never by hand-built template strings","Ask for / emit strict JSON in prompts; avoid YAML-style 'key value' output","Schema-validate tool arguments before executing so structural malformations are caught"],"tags":["json","parse","object","syntaxerror"],"backgroundTag":"json-missing-colon","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}