javaxpathxpath-3.1

How to write the Xpath for the json field having white space?


I want to write the xpath for a json field which is having white spaces in it.

[    
    {"name":"Ram", "emai ld":"ram@gmail.com", "age":23},    
    {"name":"Shyam", "email id":"shyam23@gmail.com", "age":28}
]

I tried as below to get the email id:

?1?email id

When I searched in open source I got to know this is not possible in Xpath 3.1. Xpath 4.0 supports the above as

?1?'email id'

Can somebody helps how I can use Xpath 4.0? Meaning any dependency that I need to add?


Solution

  • You need to put the string literal in parentheses:

    ?1?('email id')