{"record":{"id":"a1f77cecd85f4cc5","repo":"apple/pkl","slug":"value-a1f77c","errorCode":null,"errorMessage":"value","messagePattern":"value","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/util/json/JsonParser.java","lineNumber":139,"sourceCode":"    read();\n    skipWhiteSpace();\n    readValue();\n    skipWhiteSpace();\n    if (!isEndOfText()) {\n      throw error(\"Unexpected character\");\n    }\n  }\n\n  private void readValue() throws IOException {\n    switch (current) {\n      case 'n' -> readNull();\n      case 't' -> readTrue();\n      case 'f' -> readFalse();\n      case '\"' -> readString();\n      case '[' -> readArray();\n      case '{' -> readObject();\n      case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' -> readNumber();\n      default -> throw expected(\"value\");\n    }\n  }\n\n  private void readArray() throws IOException {\n    var array = handler.startArray();\n    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);","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/util/json/JsonParser.java#L121-L157","documentation":"The JSON parser's readValue throws 'value' expected (via expected(\"value\")) when the character at the current position cannot start any JSON value: it must be null/true/false/'\"'/'['/'{'/a number. This fires for empty input, or input starting with characters like 'u', 'True', '}', or a bare word. It is the most common JSON syntax failure and appears as the hint of jsonParseError.","triggerScenarios":"Calling `json.parse` on an empty or whitespace-only string, on `True`/`False`/`None` (Python-style literals), on a single unquoted word, or on input starting with `}` or `,`. Raised in JsonParser.readValue's default branch.","commonSituations":"Reading an empty file (zero bytes) or an HTTP response with empty body; serialized output from a non-JSON serializer (Python repr); path/expansion mistakes producing a filename string instead of file contents.","solutions":["Check that the input is non-empty before parsing","Fix the value's spelling: use lowercase true/false/null (not True/False/None)","Verify you read the file's contents, not its name (e.g. use read() properly in Pkl)","Validate the JSON externally to find the exact bad character position"],"exampleFix":"// before\nv = json.parse(flag)  // flag = \"True\"\n// after\nv = json.parse(\"true\")","handlingStrategy":"validation","validationCode":"trimmed = text.trim()\nrequire(!trimmed.isEmpty(), \"json.parse: input is empty\")\nrequire(\"[{\\\"tfn0123456789-\".contains(trimmed.substring(0, 1)),\n  \"json.parse: input does not start with a JSON value\")","typeGuard":null,"tryCatchPattern":"if (text.trim().isEmpty()) {\n  value = defaultValue\n} else {\n  value = json.parse(text)\n}","preventionTips":["Always check for empty files/bodies before parsing","Use lowercase JSON literals: true/false/null","Verify you pass file contents, not a path string"],"tags":["json","pkl","parser","empty-input"],"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"}