Ask a Question

ReadyAPI Property transfer - value from response, count of json object/array

zokirsalomov
Occasional Contributor

ReadyAPI Property transfer - value from response, count of json object/array

Hi folks,

 

I want to implement Property Transfer step in my readyapi project and trying to get value from GraphQL Request response and from the response I need to fetch count of particular json objects/arrays and save as property, for example:

  {
"data" : {
"Info" : {
"edges" : [
{
"node" : {
"info" : [
{
"nodeName" : "abc",
"code" : "abc",
"Devices" : [
       {
          "Id" : "abc",
          "dev" : "123",
          "mod" : "abc"
       },
      {
          "Id" : "abc",
          "dev" : "123",
          "mod" : "abc"
       },
     {
          "Id" : "abc",
          "dev" : "123",
          "mod" : "abc"
      }
   ]
 }
]
}
}
]
}
}
}

From above response I need to save count of devices which is 3 here, however 

$['data']['Info']['edges'][0]['node']['info'][0]['Devices'].length  -> This json path returns 3 when I run it in jsonpath.com  site, but it returns null when I use the same json path in readyApi

 

Any advice? 

 

zokirsalomov_0-1653605337105.png

 

3 REPLIES 3
ChrisAdams
Community Leader

You could try....

log.info(data.Info.edges[0].node.info[0].Devices[0].Id);
zokirsalomov
Occasional Contributor

Hi @ChrisAdams , thanks for you answer, this returns [null]

Hi,

 

OK, there is another very similar thread on this forum.  I suggested adding one item at a time...

log.info(data)
log.info(data.Info)
log.info(data.Info.edges)
log.info(data.Info.edges[0])

This might show where we have gone wrong in navigating the object.

cancel
Showing results for 
Search instead for 
Did you mean: