2

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
}
j0ker
  • 4,069
  • 4
  • 43
  • 65
paxcow
  • 1,670
  • 3
  • 17
  • 32
  • Please show what you tried so far. The JSON path extractor might be a good way to do this. http://jmeter-plugins.org/wiki/JSONPathExtractor/ – RaGe Apr 30 '15 at 14:00
  • cant compare data with path extractor. – paxcow Apr 30 '15 at 14:24

1 Answers1

0

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
vins
  • 15,030
  • 3
  • 36
  • 47
  • how can i get the index of the smallList after I do this. for example if i pick allcash_4 i need to send the index of the 4th list as a response – paxcow Apr 30 '15 at 14:59