{"record":{"id":"8a9cc52515c5e97b","repo":"apple/pkl","slug":"name","errorCode":null,"errorMessage":"name","messagePattern":"name","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/util/json/JsonParser.java","lineNumber":205,"sourceCode":"      if (!readChar(':')) {\n        throw expected(\"':'\");\n      }\n      skipWhiteSpace();\n      handler.startObjectValue(object, name);\n      readValue();\n      handler.endObjectValue(object, name);\n      skipWhiteSpace();\n    } while (readChar(','));\n    if (!readChar('}')) {\n      throw expected(\"',' or '}'\");\n    }\n    nestingLevel--;\n    handler.endObject(object);\n  }\n\n  private String readName() throws IOException {\n    if (current != '\"') {\n      throw expected(\"name\");\n    }\n    return readStringInternal();\n  }\n\n  private void readNull() throws IOException {\n    handler.startNull();\n    read();\n    readRequiredChar('u');\n    readRequiredChar('l');\n    readRequiredChar('l');\n    handler.endNull();\n  }\n\n  private void readTrue() throws IOException {\n    handler.startBoolean();\n    read();\n    readRequiredChar('r');\n    readRequiredChar('u');","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/util/json/JsonParser.java#L187-L223","documentation":"Object member names in JSON must be double-quoted strings. In readObject, before each member the parser calls readName, which checks that the current character is '\"'; if not, it throws expected(\"name\"). This rejects unquoted or wrongly-typed keys such as JavaScript-style identifiers.","triggerScenarios":"parse() on objects whose keys are not quoted: \"{name: 1}\", \"{1: 'x'}\" (numeric key), or any other token where a quoted name was required after '{' or ','.","commonSituations":"Pasting JavaScript object literals (or output of JS console.log / Python dict repr with single quotes) into a JSON config, hand-writing config files, template engines emitting {key: value} without quoting.","solutions":["Quote every object key with double quotes: {\"name\": 1} instead of {name: 1}.","Run the text through a strict-JSON formatter/validator before parsing to catch all unquoted keys at once.","If the data is a JS/Python literal, serialize it properly (JSON.stringify / json.dumps) rather than stringifying the value directly.","Catch ParseException and use its line/column to locate the offending key."],"exampleFix":"// before\nString json = \"{name: \\\"pkl\\\"}\"; // unquoted key\n// after\nString json = \"{\\\"name\\\": \\\"pkl\\\"}\";","handlingStrategy":"validation","validationCode":"// Java: detect unquoted object keys before parsing\nstatic boolean hasUnquotedKeys(String json) {\n  return java.util.regex.Pattern.compile(\"[{,]\\\\s*[A-Za-z_$][\\\\w$]*\\\\s*:\").matcher(json).find();\n}\nif (hasUnquotedKeys(json)) throw new IllegalArgumentException(\"JSON object keys must be double-quoted\");","typeGuard":null,"tryCatchPattern":"try {\n  parser.parse(json);\n} catch (ParseException e) {\n  if (e.getMessage().contains(\"name\")) {\n    throw new IllegalArgumentException(\"Unquoted or invalid object key at \" + e.getLocation().line + \":\" + e.getLocation().column, e);\n  }\n  throw e;\n}","preventionTips":["Always double-quote object keys.","Serialize JS objects/Python dicts with the proper JSON encoder, not toString.","Lint JSON files in CI to catch unquoted keys early.","Avoid pasting JavaScript literals into JSON config files."],"tags":["json","parser","syntax-error","pkl"],"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-14T16:17:12.679Z"}