{"record":{"id":"8b2436425a7d3ad8","repo":"json-path/JsonPath","slug":"expected-to-find-an-object-with-property-s-in-pat","errorCode":null,"errorMessage":"Expected to find an object with property %s in path %s but found '%s'. This is not a json object according to the JsonProvider: '%s'.","messagePattern":"Expected to find an object with property (.+?) in path (.+?) but found '(.+?)'\\. This is not a json object according to the JsonProvider: '(.+?)'\\.","errorType":"exception","errorClass":"PathNotFoundException","httpStatus":null,"severity":"error","filePath":"json-path/src/main/java/com/jayway/jsonpath/internal/path/PropertyPathToken.java","lineNumber":72,"sourceCode":"    }\n\n    public boolean multiPropertyIterationCase() {\n        // Semantics of this case is the same as semantics of ArrayPathToken with INDEX_SEQUENCE operation.\n        return !isLeaf() && properties.size() > 1;\n    }\n\n    @Override\n    public void evaluate(String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) {\n        // Can't assert it in ctor because isLeaf() could be changed later on.\n        assert onlyOneIsTrueNonThrow(singlePropertyCase(), multiPropertyMergeCase(), multiPropertyIterationCase());\n\n        if (!ctx.jsonProvider().isMap(model)) {\n            if (!isUpstreamDefinite()\n                    || ctx.options().contains(Option.SUPPRESS_EXCEPTIONS)) {\n                return;\n            } else {\n                String m = model == null ? \"null\" : model.getClass().getName();\n                throw new PathNotFoundException(String.format(\n                        \"Expected to find an object with property %s in path %s but found '%s'. \" +\n                                \"This is not a json object according to the JsonProvider: '%s'.\",\n                        getPathFragment(), currentPath, m, ctx.configuration().jsonProvider().getClass().getName()));\n            }\n        }\n\n        if (singlePropertyCase() || multiPropertyMergeCase()) {\n            handleObjectProperty(currentPath, model, ctx, properties);\n            return;\n        }\n\n        assert multiPropertyIterationCase();\n        final List<String> currentlyHandledProperty = new ArrayList<String>(1);\n        currentlyHandledProperty.add(null);\n        for (final String property : properties) {\n            currentlyHandledProperty.set(0, property);\n            handleObjectProperty(currentPath, model, ctx, currentlyHandledProperty);\n        }","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/json-path/JsonPath/blob/62a4c9f0f65ba3f625aa0867d64c528ba72d09ec/json-path/src/main/java/com/jayway/jsonpath/internal/path/PropertyPathToken.java#L54-L90","documentation":"During evaluation, PropertyPathToken needs to read a property from a JSON object (Map). If the current model node is not a Map (e.g. an array, string, number, or null), the property cannot be looked up. The library throws PathNotFoundException instead of a hard type error because the path simply does not resolve, unless SUPPRESS_EXCEPTIONS is set or the upstream path is indefinite (in which case it silently returns).","triggerScenarios":"Evaluating $.foo.bar where $.foo resolves to a string/number/array/null instead of an object; calling JsonPath.read on a document whose structure differs from the expected schema; using definite paths against documents where an intermediate node is a primitive.","commonSituations":"API responses that changed shape (field is now a scalar or missing); reading paths like $.user.name when user is null; querying arrays with object-property paths without the correct [?] filter or ['..'] wildcard; mismatched schema between producer and consumer services.","solutions":["Fix the path so it matches the actual document shape (add array iteration [*] or filters where the node is an array)","Validate/inspect the document before reading (e.g. read the parent node and check it is a Map)","Add Option.SUPPRESS_EXCEPTIONS to the Configuration if a miss is acceptable and null/absence should be tolerated","Use definitive(...) or JsonPath.parse(...).read with default value handling (read(path, default)) for optional fields"],"exampleFix":"// before\nString name = JsonPath.read(json, \"$.user.name\"); // throws if user is a string/null\n// after\nObject user = JsonPath.read(json, \"$.user\");\nString name = (user instanceof Map) ? JsonPath.read(json, \"$.user.name\") : null;","handlingStrategy":"type-guard","validationCode":"Object parent = JsonPath.read(json, \"$.user\");\nif (!(parent instanceof Map)) throw new IllegalStateException(\"$.user is not an object\");","typeGuard":"boolean isObject(Object o) { return o instanceof Map<?, ?>; }","tryCatchPattern":"try {\n    return JsonPath.read(json, \"$.user.name\");\n} catch (PathNotFoundException e) {\n    return null; // or default value\n}","preventionTips":["Align paths with the actual document schema; inspect samples first","Use Option.SUPPRESS_EXCEPTIONS for optional lookups","Add contract tests asserting API response shape","Prefer read(path, defaultValue) for optional fields"],"tags":["json-path","path-not-found","type-mismatch"],"backgroundTag":"resource-not-found","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"}