Browse Source

Fixed null issue.

pull/148/head
Kalle Stenflo 9 years ago
parent
commit
6353b20ad4
  1. 6
      json-path/src/main/java/com/jayway/jsonpath/internal/token/PropertyPathToken.java

6
json-path/src/main/java/com/jayway/jsonpath/internal/token/PropertyPathToken.java

@ -38,8 +38,10 @@ class PropertyPathToken extends PathToken {
@Override @Override
public void evaluate(String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) { public void evaluate(String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) {
if (!ctx.jsonProvider().isMap(model)) { if (!ctx.jsonProvider().isMap(model)) {
//throw new PathNotFoundException("Property " + getPathFragment() + " not found in path " + currentPath);
throw new PathNotFoundException("Expected to find an object with property " + getPathFragment() + " but found '" + model.getClass().getName() + "'. This is not a json object according to the JsonProvider: '" + ctx.configuration().jsonProvider().getClass().getName() + "'."); String m = model == null ? "null" : model.getClass().getName();
throw new PathNotFoundException("Expected to find an object with property " + getPathFragment() + " but found '" + m + "'. This is not a json object according to the JsonProvider: '" + ctx.configuration().jsonProvider().getClass().getName() + "'.");
} }
handleObjectProperty(currentPath, model, ctx, properties); handleObjectProperty(currentPath, model, ctx, properties);

Loading…
Cancel
Save