AKADO
AKADO

Reputation: 481

SoapUI - how to count the jsonArray (as response in transfer Properties in soapUI)

I am trying since half day to get the count of the JSON array Response in a Transfer variable using SoapUi (Basic Version 5.2.1). - please see screen shot enter image description here

I get as a response of a REST API as a JSON array and want to get the number of all attribute rel in Json Record (In soapUI by passing it in to a Transfer propertystep) - please see screenshot.

Can someone help me to resolve this issue? Thanks for any support!

I have already tried the following but no success:

($..links[?(@.href == '/admin/verfahren')].rel).length()
($..links[?(@.href == '/admin/verfahren')].rel).length
($..links[?(@.href == '/admin/verfahren')].rel).size()
($..links[?(@.href == '/admin/verfahren')].rel).size

In all case, I get an empty response [[]]

count($..links[?(@.href == '/admin/verfahren')].rel)

In this case also nothing.

Here is one record of REST API JSON response:

[
      {
      "dto_id": 1,
      "bezeichnung": "ABBA",
      "itnummer": null,
      "verfahrenskategorie":       {
         "dto_id": 3,
         "Schluessel": "B",
         "bezeichnung": "Best-Effort",
         "links": []
      },
      "berechtigteADGruppe": "Administrators",
      "verfahrensKuerzel": null,
      "links":       [
                  {
            "rel": "create",
            "href": "/admin/verfahren",
            "hreflang": null,
            "media": null,
            "title": null,
            "type": null,
            "deprecation": null
         },
                  {
            "rel": "self",
            "href": "/admin/verfahren/1",
            "hreflang": null,
            "media": null,
            "title": null,
            "type": null,
            "deprecation": null
         },
                  {
            "rel": "update",
            "href": "/admin/verfahren/1",
            "hreflang": null,
            "media": null,
            "title": null,
            "type": null,
            "deprecation": null
         },
                  {
            "rel": "delete",
            "href": "/admin/verfahren/1",
            "hreflang": null,
            "media": null,
            "title": null,
            "type": null,
            "deprecation": null
         }
      ]
   },
{.......
.......
]

And here also the response what I am trying to get the count of it:

[[creat, creat, creat , ......] - see screenshot

Upvotes: 3

Views: 513

Answers (1)

Ehcnalb
Ehcnalb

Reputation: 476

I don't know if you found the answer since, but I propose you this :
Put your property in ResponseAsXml and path language as XPath then :

${#ResponseAsXml#count(//*:rel)}

Look at this
Hope it can help you

Upvotes: 1

Related Questions