Forum Discussion

zokirsalomov's avatar
zokirsalomov
Occasional Contributor
2 years ago

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? 

 

 

3 Replies

  • ChrisAdams's avatar
    ChrisAdams
    Champion Level 2

    You could try....

    log.info(data.Info.edges[0].node.info[0].Devices[0].Id);
      • ChrisAdams's avatar
        ChrisAdams
        Champion Level 2

        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.