spark85 / json-path

Automatically exported from code.google.com/p/json-path
0 stars 0 forks source link

JsonPath.compile(path).getPath() doesn't return correct path using dot notation (version 1.2.0) #63

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
It's a minor issue with version 1.2.0. It works with 0.9.0. The String 
representation of the path returned after you compile the path is not the same 
with a predicate using dot notation.

See attached JUnit test case.

Original issue reported on code.google.com by emilio.r...@gmail.com on 4 Dec 2014 at 6:58

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by kalle.st...@gmail.com on 8 Dec 2014 at 6:47

GoogleCodeExporter commented 9 years ago
Your bracket notation is not correct. It should be:

String path = "$['store']['book'][?(@.price > 10)]['title']";

is same as:

String path = "$.store.book[?(@.price > 10)].title";

Original comment by kalle.st...@gmail.com on 8 Dec 2014 at 8:02

GoogleCodeExporter commented 9 years ago
Yes, sorry. I made a mistake with the bracket notation. But the issue I tried 
to report was with the testDotNotation() test case. The path returned from the 
compiled path is not the same we provide (and I do not mean exactly the same, I 
mean that the returned path is not semantically the same).  The output of these 
statements:

String path = "$.store.book[?(@.price > 10)].title";
JsonPath jsonPath = JsonPath.compile(path);
System.out.println("testDotNotation: Compiled path returned: "+ 
jsonPath.getPath());

is

testDotNotation: Compiled path returned: $['store']['book'][?]['title']

The bracket notation returned is not the same, right?

Thanks a lot for the quick reply.

Original comment by emilio.r...@gmail.com on 9 Dec 2014 at 2:56