Search code examples
jsonapijmeterresponsejsonpath

Jmeter Key Extraction value in the response


I want to extract the key value generated from response, is there's a way to simulate using JSON Path extractor?

Sample Response:

{
    "data": {
        "1637042070532561": {
            "symbol": "BAUa",
            "side": "buy",
            "quantity": "1",
            "limitPrice": "2145",
            "instrumentId": 4,
            "created": "1637042070533",
            "orderStatus": "rejected",
            "type": "limit",
            "executions": {
            },
            "decimals": 2,
            "commission": "0",
            "currency": "EUR",
            "averagePrice": "0",
            "id": "1637042070532561",
            "filledStatus": "unfilled",
            "filledPercent": "0.00",
            "filledQty": "0"
        }
    },
    "action": "set-orders",
    "type": "orders",
    "status": "OK",
    "timestamp": "2021-11-16T05:54:30.536Z"
}

Expected Result: 1637042070532561


Solution

  • Go for JSON JMESPath Extractor, it provides keys function allowing querying JSON attribute names, in your case the query would be something like:

    keys(data)
    

    Demo:

    enter image description here

    More information: The JMeter JSON JMESPath Extractor and Assertion: A Guide