Quantcast
Channel: [Q&A - FAQ Neotys] Last questions
Viewing all articles
Browse latest Browse all 2283

How to store JSON array of values individually to separate variables?

$
0
0

Requirement: To sum up all the "availableAmount" values in the below JSON and store into a variable.

JSON:
[{
"id": 0,
"availableAmount": 100.55
},
{
"id": 0,
"availableAmount": 200.87
},
{
"id": 0,
"availableAmount": 357.54
}]

My Approach:
1. Use JSON Extractor "$[*].availableAmount" to get an array of values and store them to a correlated variable.Here, the wildcard extracts all of the matching values. So the varaible will contain values [100.55,200.87,357.54]
2. Store the above array of values individually to separate variables. eg. a=100.55, b=200.87, c=357.54
3. Store the sum of a,b and c to another variable, i.e. d=a+b+c

How to perform Steps 2 and 3 in NeoLoad? Please provide suggestions if there is a better approach.


Viewing all articles
Browse latest Browse all 2283

Trending Articles