如何在XSLT中从JSON提取数据?
我在XSLT中调用一个rest服务,作为回报得到JSON响应 如何使用XSLT从JSON响应中提取数据。下面是调用rest服务的XSLT代码,并给出了JSON响应。从JSON响应中,我需要提取如何在XSLT中从JSON提取数据?,json,xml,xslt,Json,Xml,Xslt,我在XSLT中调用一个rest服务,作为回报得到JSON响应 如何使用XSLT从JSON响应中提取数据。下面是调用rest服务的XSLT代码,并给出了JSON响应。从JSON响应中,我需要提取Cookie1、Cookie2和Cookie3的值 XSLT <xsl:variable name="result1"> <dp:url-open target="{$abc}" response="binaryNode" resolve-mode
Cookie1
、Cookie2
和Cookie3
的值
XSLT
<xsl:variable name="result1">
<dp:url-open target="{$abc}" response="binaryNode"
resolve-mode="xml" data-type="xml" http-method="post">
</dp:url-open>
</xsl:variable>
<xsl:variable name="json">
<xsl:value-of select="dp:decode(dp:binary-encode($result1/result/binary/node()),
'base-64' )" />
</xsl:variable>
请让我知道如何使用XSLT实现这一点。XSLT 3.0/XPath 3.1
用于返回a,然后获取感兴趣的值。
<xsl:variable name="ValidationResponse">
<dp:url-open target="{$url}"
response="responsecode-binary" http-method="GET"
content-type="application/x-www-form-urlencoded"
ssl-proxy="abc" http-headers="$headerValues" />
</xsl:variable>
<dp:set-variable name="'var://context/sample/valResp'"
value="normalize-space($ValidationResponse)"/>
然后使用convert查询参数或其他XSLT转换输出,以获得所需的输出。这是前面问题的重复。除非您使用XSLT 3.0处理器,否则没有内置的标准化支持,您应该首先检查您的XSLT处理器(DataPower?)是否有一些扩展函数或指令来处理JSON数据。@SimonBlack:这个问题通常是关于将JSON转换为XML的。这个问题没有那么雄心勃勃:它只是想知道如何使用XSLT从JSON中提取数据。(我已经修改了标题以反映所问的实际问题)或者使用fn:json-to-xml()将json转换为节点树,并使用XPath表达式选择节点树。
<xsl:variable name="ValidationResponse">
<dp:url-open target="{$url}"
response="responsecode-binary" http-method="GET"
content-type="application/x-www-form-urlencoded"
ssl-proxy="abc" http-headers="$headerValues" />
</xsl:variable>
<dp:set-variable name="'var://context/sample/valResp'"
value="normalize-space($ValidationResponse)"/>