soapUI中JSON响应的xPath

soapUI中JSON响应的xPath,json,xpath,soapui,Json,Xpath,Soapui,有人可以帮助查找下面给出的JSON响应中的'tenantId'的xpath吗 { "statusCode": "200", "errorParams": null, "payLoad": { "UGX:XCD": { "id": 42802, "fromCurrency": { "tenantId": "2a610af6-2e42-4a78-8e04-98755e2c61

有人可以帮助查找下面给出的JSON响应中的'tenantId'的xpath吗

{
   "statusCode": "200",
   "errorParams": null,
   "payLoad":    {
      "UGX:XCD":       {
         "id": 42802,
         "fromCurrency":          {
            "tenantId": "2a610af6-2e42-4a78-8e04-98755e2c6113",
            "code": "UGX",
            "name": "Ugandan Shilling",
            "isoCode": "UGX",
            "active": true,
            "enabled": true,
            "flagModifiedName": false,
            "erpId": null,
            "createdOn": 1427155200000,
            "fieldLibraryStatus": "DRAFT",
            "userId": null
         },
         "toCurrency":          {
            "tenantId": "2a610af6-2e42-4a78-8e04-98755e2c6113",
            "code": "XCD",
            "name": "East Caribbean Dollar",
            "isoCode": "XCD",
            "active": true,
            "enabled": true,
            "flagModifiedName": true,
            "erpId": null,
            "createdOn": 1427155200000,
            "fieldLibraryStatus": "DRAFT",
            "userId": "c7f68b05-044d-44e1-8fc5-0f97a4ece91b"
         },
         "rate": 33,
         "inverseRate": 0.0303,
         "createdOn": 1434025926983,
         "modifiedOn": 1434326400000,
         "active": true,
         "purpose": "cmd",
         "enabled": true,
         "tenantFlag": true,
         "erpId": null
      }
如何穿越到“tenantId”


提前感谢。

SoapUI在内部将几乎所有内容转换为XML。您必须使用
ResponseAsXml
属性。在GUI中,如果单击XML选项卡,可以看到这种表示

类似于以下的方法应该可以工作:

${test_step#ResponseAsXml#//*:fromCurrency/*:tenantId}
${test_step#ResponseAsXml#//*:toCurrency/*:tenantId}

如果您想使用groovy处理这个问题,那么可以使用Google提供的GSON.jar库扩展SOAPUI。 这个库是专门为处理JSON对象而编写的


有了它,您可以轻松地删除每个单独的对象及其属性值JSON对象可能有多复杂,这是一个很好的附加组件。

XPath用于选择XML文档的部分。它具有基本的字符串处理能力,但不是遍历JSON数据结构的好工具。如果您告诉我们您想要在什么环境中使用XPath,也许我们可以建议一种更好的方法来处理JSON数据。我认为这是没有必要的,gdk中的groovy有一个很好的类来处理JSON
:)