vigossjjj/json-path

keys with "."

Closed this issue · 2 comments

Create a doc e.g. like this {"rootkey":{"sub.key":"value"}} and try to select 
the value

with a path like "rootkey.sub.key" you will get a "PathNotFoundException" 
stating that there is no key named sub.

Is it possible to express the path in some other way to get the value?

I'm on jsonpath 0.9.0!


/Jesper

Original issue reported on code.google.com by jeppe.bl...@gmail.com on 20 Feb 2014 at 2:38

never mind, found a solution...
you can do this rootkey.[sub.key]


/Jesper

Original comment by jeppe.bl...@gmail.com on 20 Feb 2014 at 2:56

You must use bracket notation to target this property:


        String json = "{\"rootkey\":{\"sub.key\":\"value\"}}";

        assertThat(JsonPath.read(json, "rootkey['sub.key']")).isEqualTo("value");

Original comment by kalle.st...@gmail.com on 4 Aug 2014 at 10:20

  • Changed state: Invalid