Documentation

GetJSONValueHandler function

GetJSONValueHandler function is used to  get the specified value from JSON.

Select SET command from the action dropdown and provide a variable name in Element key, edit parameter section and click on Form, select functions from the dropdown and select GETJSONVALUEHANDLER function. Provide jsonObject(JSON data) and key to fetch the value from the given json.

For Example: We have a sample JSON as given below:

{‘session’:{‘name’:’JSESSIONID’,’value’:’85DEE2B96942D19A1CC638B16721EB77′,”data”:{“key”:”value”}},’loginInfo’:{‘loginCount’:3,’previousLoginTime’:’2020-03-27T14:34:51.664+0530′}}

Here we want to fetch the name which is JSESSIONID so the corresponding key will be session.name. As we get inside the hierarchy of the JSON we will be using dot(.) for fetching the desired value.

Once we have the data in the variable defined in element key you can use it in your further steps for validations or any other requirement that you have with this data.

After saving this function it will look as below:

Since, JSON data are sometimes big we can first store that data in a variable and then we can use that variable in GETJSONVALUEHANDLER function as shown below:

Step 1: We have used a variable to store our JSON data.

Step 2: Variable used in the above step is used as the input JSON object.

Step 3: Verifying the actual value and the expected value.

Was this page helpful?