salilbc / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

JSONPath fails to escape if "." and "-" are used in one String #172

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Here is a unittest to reproduce the Problem:

    @Test
    public void testDotEscaping() {
        JsonPath path = new JsonPath("{ \"a-b\"  : \"minus\" , \"a.b\" : \"dot\"  , \"a.b-c\" : \"both\"  }" );
        assertEquals ("minus", path.get ("'a-b'")); // works
        assertEquals ("minus", path.get ("a-b")); // works

        assertEquals ("dot", path.get ("'a.b'")); // works

        assertEquals ("both", path.get ("'a\\u002Eb-c'")); // works, Workaround for problem in next line

        assertEquals ("both", path.get ("'a.b-c'")); //  Fails: "No such property b for class: Script1"
    }

This is not as far fetched as it might seem. It occurs quite naturaly when 
using urls as keys. For Example: http://de.example.com/some-path.

Original issue reported on code.google.com by martinEi...@gmail.com on 16 May 2012 at 11:41

GoogleCodeExporter commented 9 years ago
Thanks for reporting. It's been fixed in trunk. Please try it out by depending 
on version 1.6.2-SNAPSHOT after having added the following repo in your pom:

<repositories>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <snapshots />
        </repository>
</repositories>

Original comment by johan.ha...@gmail.com on 18 May 2012 at 10:53

GoogleCodeExporter commented 9 years ago
Thanks for fixing. I tried and can confirm it works for my real world Problem 
in 1.6.2-SNAPSHOT.

Original comment by martinEi...@gmail.com on 24 May 2012 at 5:45

GoogleCodeExporter commented 9 years ago
great! Thanks for trying it out.

Original comment by johan.ha...@gmail.com on 24 May 2012 at 10:56