{"record":{"id":"0c7a98bfd8a9a647","repo":"json-path/JsonPath","slug":"jsonpathexception","errorCode":null,"errorMessage":"JsonPathException","messagePattern":"JsonPathException","errorType":"exception","errorClass":"JsonPathException","httpStatus":null,"severity":"error","filePath":"json-path/src/main/java/com/jayway/jsonpath/spi/json/JakartaJsonProvider.java","lineNumber":86,"sourceCode":"    }\r\n\r\n    @Override\r\n    public Object parse(String json) throws InvalidJsonException {\r\n        return parse(new StringReader(json));\r\n    }\r\n\r\n    @Override\r\n    public Object parse(byte[] json)\r\n        throws InvalidJsonException {\r\n        return parse(new InputStreamReader(new ByteArrayInputStream(json), StandardCharsets.UTF_8));\r\n    }\r\n\r\n    @Override\r\n    public Object parse(InputStream jsonStream, String charset) throws InvalidJsonException {\r\n        try {\r\n            return parse(new InputStreamReader(jsonStream, charset));\r\n        } catch (UnsupportedEncodingException e) {\r\n            throw new JsonPathException(e);\r\n        }\r\n    }\r\n\r\n  private Object parse(Reader jsonInput) {\r\n    try (JsonReader jsonReader = defaultJsonProvider.createReader(jsonInput)) {\r\n        JsonStructure jsonStruct = jsonReader.read();\r\n        return mutableJson ? proxyAll(jsonStruct) : jsonStruct;\r\n    } catch (JsonParsingException e) {\r\n        throw new InvalidJsonException(e);\r\n    }\r\n    // not catching a JsonException as it never happens here\r\n  }\r\n\r\n    @Override\r\n    public String toJson(Object obj) {\r\n        if (obj instanceof JsonObjectBuilder) {\r\n            obj = ((JsonObjectBuilder) obj).build();\r\n        } else if (obj instanceof JsonArrayBuilder) {\r","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/json-path/JsonPath/blob/62a4c9f0f65ba3f625aa0867d64c528ba72d09ec/json-path/src/main/java/com/jayway/jsonpath/spi/json/JakartaJsonProvider.java#L68-L104","documentation":"JakartaJsonProvider.parse(InputStream, charset) delegates to a Reader-based parse; if constructing the InputStreamReader throws UnsupportedEncodingException (an invalid charset name), it is rethrown as JsonPathException. This is a configuration/argument error, not a JSON syntax problem.","triggerScenarios":"Calling parse(InputStream, charset) with a charset name not supported by the JVM, e.g. a misspelled 'UTF8 '-' variant issue or an exotic charset on a minimal JRE.","commonSituations":"Hard-coded charset strings from config files, charsets coming from HTTP headers that are invalid, or running on a stripped JVM lacking optional charset providers.","solutions":["Use StandardCharsets.UTF_8.name() (or another guaranteed standard charset) instead of free-form strings.","Validate charset names with Charset.isSupported(name) before calling parse.","Prefer the parse(String) or parse(byte[]) style APIs that avoid explicit charset handling."],"exampleFix":"// before\nObject doc = JsonPath.parse(stream, \"utf-8\");\n// after\nObject doc = JsonPath.parse(stream, StandardCharsets.UTF_8.name());","handlingStrategy":"validation","validationCode":"// Java\nif (!Charset.isSupported(charsetName)) throw new IllegalArgumentException(\"Unsupported charset: \" + charsetName);","typeGuard":null,"tryCatchPattern":"try { return JsonPath.parse(stream, charset); } catch (JsonPathException e) { throw new IllegalArgumentException(\"Bad charset\", e); }","preventionTips":["Use StandardCharsets.*.name()","Never pass charset strings from unvalidated config/headers","Prefer parse(String) when the source is already decoded"],"tags":["json","charset","encoding","parsing"],"backgroundTag":"invalid-argument-value","analyzedSha":"62a4c9f0f65ba3f625aa0867d64c528ba72d09ec","analyzedAt":"2026-09-11T11:36:00.448Z","contentChangedAt":"2026-09-11T11:36:00.448Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}