Can't match paths in which the slash ("/") is escaped.

899 views
Skip to first unread message

Tom

unread,
Feb 28, 2014, 5:39:23 PM2/28/14
to json...@googlegroups.com
I was using JsonPath.read( jo, path ) successfully with paths that includes the forward slash, but then I started creating my JSON by parsing strings using json-simple, which escapes the slash ("/") character.

I thought the solution would be simple: just do the same escaping of my path string, but this doesn't solve the problem.

My Java code looks like this:

public String escapedPath = "$.property.\\/first\\/second.value";

And this produces a path = "$.property.\/first\/second.value", which exactly matches path element in my JSON, but attempting a read with this path produces:

com.jayway.jsonpath.PathNotFoundException: Path '\/first\/second' not found in the current context: ...

Note that having the escaped / at the beginning of an element, having two them, etc. made no difference - I tried many variations.  The only thing that makes it work is to return to un-escaped slashes.

I'm using JsonPath 0.9.0 on GAE 1.8.9.

Thanks, Tom
Reply all
Reply to author
Forward
0 new messages