I'm trying to extract the all "cash" values from SmallerList (into a list or an array) and compare them with each other, and later use the top value on a new request.
I have been trying to write a script in BeanShell PostProcessor and failing. Any recommendations? Thanks
{
"SomeList": {
"SmallerList": [{
"name": "aaa",
"sample": "Hrazerggsl2",
"NO": "156576321467",
"data": "917",
"xyzxyz": "TAKEOUT",
"dadada": "64,04 USD",
"cash": "64,04 USD",
"asdasde": "0,00 USD",
"asdasdw": "833248",
"asdasdd": 0,
"dsdfi": true,
"ewqwe": false,
"ewqewq": false,
"irqfsais": true,
"gggggg": false,
"asdasda": false,
"gffffv": false
}, {
"name": "aaa",
"sample": "Hrazerggsl2",
"NO": "156576321467",
"data": "917",
"xyzxyz": "TAKEOUT",
"dadada": "94,04 USD",
"cash": "154,04 USD",
"asdasde": "0,00 USD",
"asdasdw": "833248",
"asdasdd": 0,
"dsdfi": true,
"ewqwe": false,
"ewqewq": false,
"irqfsais": true,
"gggggg": false,
"asdasda": false,
"gffffv": false
}, {
"name": "aaa",
"sample": "Hrazerggsl2",
"NO": "156576321467",
"data": "917",
"xyzxyz": "TAKEOUT",
"dadada": "64,04 USD",
"cash": "624,04 USD",
"asdasde": "0,00 USD",
"asdasdw": "833248",
"asdasdd": 0,
"dsdfi": true,
"ewqwe": false,
"ewqewq": false,
"irqfsais": true,
"gggggg": false,
"asdasda": false,
"gffffv": false
}],
"drqwname": "aadasdaa",
"sample": "Hdasdrazerggsl2",
"NO": "156576321467",
"data": "917",
"xyzxyz": "TAKEOUT",
"dadada": "64,04 USD",
"cash": "64,04 USD",
"asdasde": "0,00 USD",
"asdasdw": "833248",
"asdasdd": 0,
"dsdfi": true,
"ewqwe": false,
"ewqewq": false,
"irqfsais": true,
"gggggg": false,
"asdasda": false,
"gffffv": false
},
"list": {
"payment": [{
"name": "asdasdasdasd"
}, {
"name": "asdasrqweqwe"
}, {
"name": "asgfdsf"
}, {
"name": "asdfasdfa"
}],
"name": "dad"
},
"success": true
}
Use JSON Path Extractor. It is very easy to use.
Check this for the path expressions to be used. (scroll down to the section - The Differences Between XPath and JSONPath)
In your case, $..cash
will return all the cash
as given below.
allcash
is the variable i used.
allcash=["64,04 USD","64,04 USD","154,04 USD","624,04 USD"]
allcash_1=64,04 USD
allcash_2=64,04 USD
allcash_3=154,04 USD
allcash_4=624,04 USD