Forum Discussion

frankthemaster's avatar
frankthemaster
New Contributor
9 years ago
Solved

Need help pasrsing api response

Hi all,

 

I'm new to testcomplete and I'm assigned to write test scripts using jscript for some API testing. For one of the test, I need to parse JSON response and retrive a key of some sort and save it. I can't seems to wrap my hand around it and figure it out. Any help would be appreciated.

 

Following is API response -

{
"date":"2016-12-31T00:00:00.0000000",
"accountid":"8675309",,
"license_mode":"mode1",
"user_email":"primaryuser@gmail.com",
"key":"0efca74a-7f9b-41f8-96a9-b05a3367854a",
}

and I need to retrive the key and save it for later use.

 

function Get_Key (responsetxt)
{
  var name = "key"
  var qs = dotNET.System_Web.HttpUtility.ParseQueryString(responsetext);
  var strValue = qs.Item(name).OleValue;
}

that's all I have so far.

 

Thank you very much for taking time out to help me.

 

5 Replies