-3
[
    {
        "id": 1,
        "name": "MetaOperationN1",
        "type": "Operation"
    },
    {
        "id": 2,
        "name": "GreenOper2",
        "type": "Operation"
    },
    {
        "id": 3,
        "name": "GreenOper4",
        "type": "Operation"
    },
    {
        "id": 4,
        "name": "GreenOper5",
        "type": "Operation"
    },
    {
        "id": 5,
        "name": "GreenOper6",
        "type": "Operation"
    },
    {
        "id": 6,
        "name": "GreenOper7",
        "type": "Operation"
    },
    {
        "id": 7,
        "name": "GreenOper8",
        "type": "Operation"
    },
    {
        "id": 8,
        "name": "GreenOper9",
        "type": "Operation"
    },
    {
        "id": 9,
        "name": "GreenOper10",
        "type": "Operation"
    },
    {
        "id": 10,
        "name": "GreenOper11",
        "type": "Operation"
    }
]
Alan Moore
  • 73,866
  • 12
  • 100
  • 156
Rohit
  • 1
  • 2

2 Answers2

1
  1. Using Regular Expression Extractor with following configuration:

    • Reference Name: anything meaningful, i.e. ID
    • Regular Expression: "id": (\d+),
    • Template: $1$
    • Match No.: -1
  2. Using JSON Path Extractor (available via JMeter Plugins)

    • Reference Name: whatever you want, i.e. ID
    • JSONPath Expression: $..id

In both cases you'll get IDs list as:

ID_1=1
ID_10=10
ID_2=2
ID_3=3
ID_4=4
etc.

For more information on installing JSON Path Extractor and regarding JSON Path language check out Using the XPath Extractor in JMeter (scroll down to "Parsing JSON")

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
0

Dont use regex for parsing json docs.. easily done by referring this

If you want to use regex.. go ahead:

"id": (\d+)

And extract out ids with $1

Community
  • 1
  • 1
karthik manchala
  • 13,492
  • 1
  • 31
  • 55