RuddenberryL / json-path

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

Normalized path expressions do not escape '. #70

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. {"']['" : "bar"} with $..*.

What is the expected output? What do you see instead?
It produces $['']['']. I would expect something like  produces $['\'][\''], so 
the ' escaped.

What version of the product are you using? On what operating system?
1.3.0 SNAPSHOT (07a515245135e3bc7d8d63054f856a7ee9032dee)

Example test cases:
        Configuration conf = Configuration.builder().options(AS_PATH_LIST).build();

        List<String> pathList = using(conf).parse("{\"']['\" : \"bar\"}").read("$..*");

        assertThat(pathList).containsOnly("$['\\'][\\'']");

For handling escaped jsonpaths:
//This should work only if assuming no escaping is necessary
//      Configuration conf = Configuration.builder().build();
//      assertThat(using(conf).parse("{\"']['\" : 
\"bar\"}").read("$['']['']")).isEqualTo("bar");

//This should work assuming escaping is unevitable and the escaping character 
is \:
        Configuration conf = Configuration.builder().build();
        assertThat(using(conf).parse("{\"']['\" : \"bar\"}").read("$['\\'][\\'']")).isEqualTo("bar");

Probably the backslash character has to be escaped in the paths too, so 
{"\\" : "bar"} with $..* should return normalized path $['\\'] (which is 
currently works as expected) and $['\\'] query should return "bar" (but only 
$['\'] returns bar), but it results in no results.

Original issue reported on code.google.com by bakos.ga...@mind-era.com on 8 Mar 2015 at 7:28

GoogleCodeExporter commented 9 years ago
Should I file this (and also 
https://code.google.com/p/json-path/issues/detail?id=67) as an issue on github?

Original comment by bakos.ga...@mind-era.com on 31 Mar 2015 at 4:10