Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rest 可以使用JSONPath或XPath获取查询字符串吗?_Rest_Xpath_Oauth_Jsonpath_Insomnia - Fatal编程技术网

Rest 可以使用JSONPath或XPath获取查询字符串吗?

Rest 可以使用JSONPath或XPath获取查询字符串吗?,rest,xpath,oauth,jsonpath,insomnia,Rest,Xpath,Oauth,Jsonpath,Insomnia,我目前正在使用失眠应用程序创建一些请求和一个API响应,我得到一个带有“redirect_uri”字段的JSON,该值实际上是一个URL 我只需要获取代码参数,因此在以下示例中,JSONPath或XPath需要返回8748d39f-1d4f-311f-92c6-4b279db1b317: { "redirect_uri": "http://www.google.com?state=string&code=8748d39f-1d4f-311f-92c6-4b279db1b317" }

我目前正在使用失眠应用程序创建一些请求和一个API响应,我得到一个带有“redirect_uri”字段的JSON,该值实际上是一个URL

我只需要获取
代码参数
,因此在以下示例中,JSONPath或XPath需要返回
8748d39f-1d4f-311f-92c6-4b279db1b317

{
  "redirect_uri": "http://www.google.com?state=string&code=8748d39f-1d4f-311f-92c6-4b279db1b317"
}
要返回的值:
8748d39f-1d4f-311f-92c6-4b279db1b317


可以使用JSONPath或XPath吗?

您可以使用这个有点复杂的XPath表达式:

substring-before(substring-after('{
  "redirect_uri": "http://www.google.com?state=string&code=8748d39f-1d4f-311f-92c6-4b279db1b317"
}',
'code='),'"')

谢谢这很有效。我会根据我的要求调整它