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

65 Views Asked by At

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

[    
    {"name":"Ram", "emai ld":"[email protected]", "age":23},    
    {"name":"Shyam", "email id":"[email protected]", "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?

2

There are 2 best solutions below

0
Michael Kay On BEST ANSWER

You need to put the string literal in parentheses:

?1?('email id')
4
Martin Honnen On

Or just call the map with e.g. ?1('email id').