{"record":{"id":"6934063dab0966f0","repo":"apple/pkl","slug":"or","errorCode":null,"errorMessage":"',' or ']'","messagePattern":"',' or '\\]'","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/util/json/JsonParser.java","lineNumber":163,"sourceCode":"    read();\n    if (++nestingLevel > MAX_NESTING_LEVEL) {\n      throw error(\"Nesting too deep\");\n    }\n    skipWhiteSpace();\n    if (readChar(']')) {\n      nestingLevel--;\n      handler.endArray(array);\n      return;\n    }\n    do {\n      skipWhiteSpace();\n      handler.startArrayValue(array);\n      readValue();\n      handler.endArrayValue(array);\n      skipWhiteSpace();\n    } while (readChar(','));\n    if (!readChar(']')) {\n      throw expected(\"',' or ']'\");\n    }\n    nestingLevel--;\n    handler.endArray(array);\n  }\n\n  private void readObject() throws IOException {\n    var object = handler.startObject();\n    read();\n    if (++nestingLevel > MAX_NESTING_LEVEL) {\n      throw error(\"Nesting too deep\");\n    }\n    skipWhiteSpace();\n    if (readChar('}')) {\n      nestingLevel--;\n      handler.endObject(object);\n      return;\n    }\n    do {","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/util/json/JsonParser.java#L145-L181","documentation":"The JSON parser throws expected(\"',' or ']'\") when, inside an array, after a value it encounters neither a `,` (next element) nor `]` (array end). Typically caused by a missing comma between elements, an unquoted string, or a stray character inside `[...]`. Surfaces as the hint of jsonParseError from `json.parse`.","triggerScenarios":"Input like `[1 2]`, `[\"a\" \"b\"]`, `[1, 2 ,]`-style mistakes resolved wrong, or `[1, 2 x]`. Raised in JsonParser.readArray when readChar(']') fails after the element loop.","commonSituations":"Hand-written JSON with missing commas; values containing raw quotes or characters that terminate strings early; copy-paste from non-JSON sources (JS arrays without quotes); template artifacts inside arrays.","solutions":["Insert the missing comma between array elements at the position from the hint","Quote any unquoted strings in the array","Remove stray characters (extra identifiers, comments) inside the array","Validate the JSON with a linter to pinpoint the exact offending position"],"exampleFix":"// before\nv = json.parse(\"[1 2, 3]\")\n// after\nv = json.parse(\"[1, 2, 3]\")","handlingStrategy":"try-catch","validationCode":"// quote balance sanity check inside arrays\ninStr = false; text.chars.forEach((c) -> {\n  if (c == '\"') inStr = !inStr\n})\nrequire(!inStr, \"unbalanced quotes in JSON input\")","typeGuard":null,"tryCatchPattern":"try {\n  value = json.parse(text)\n} catch (e) {\n  trace(\"JSON syntax error: ${e.message}\")  // hint points at ',' or ']' expectation\n  throw e\n}","preventionTips":["Comma-separate every array element; run jsonlint on hand-written JSON","Escape quotes inside JSON strings properly","Generate JSON via a serializer instead of string concatenation"],"tags":["json","pkl","parser","syntax"],"backgroundTag":"json-parse-error","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}