Skip to content

Commit

Permalink
bug fixed for jsonpath
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Nov 29, 2018
1 parent 3efede7 commit 9c2e59f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/alibaba/fastjson/JSONPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ public Object extract(DefaultJSONParser parser) {
return this.eval(root);
}

if (segments.length == 0) {
return parser.parse();
}

Context context = null;
for (int i = 0; i < segments.length; ++i) {
Segment segment = segments[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@ public void test_1() throws Exception {
, JSONPath.extract(json, "$.f2")
.toString());
}

public void test_2() throws Exception {
assertEquals("{}"
, JSONPath.extract("{}", "$")
.toString());
}
}

0 comments on commit 9c2e59f

Please sign in to comment.