Home > Mobile >  JMeter: Capturing JSON (GET) Thread Group-1, modify value and Send in another request (PUT) as a pay
JMeter: Capturing JSON (GET) Thread Group-1, modify value and Send in another request (PUT) as a pay

Time:08-20

How to JSON (GET) Thread Group-1, modify value and Send in another request (PUT) as a payload (Thread Group-2), my scenario as below

enter image description here

Sample JSON response received from Request(GET)

{
"glossary": {
    "title": "example glossary",
    "GlossDiv": {
        "title": "S",
        "GlossList": {
            "GlossEntry": {
                "ID": "SGML",
                "SortAs": "SGML",
                "GlossTerm": "Standard Generalized Markup Language",
                "**Acronym**": "SGML",
                "Abbrev": "ISO 8879:1986",
                "GlossDef": {
                    "para": "A meta-markup language, used to create markup languages such as DocBook.",
                    "GlossSeeAlso": ["GML", "XML"]
                },
                "GlossSee": "markup"
            }
        }
    }
}

}

Any pointers is highly appreciated, thank you so much!

Best wishes, Ashwin

CodePudding user response:

You can do this using JSR223 PostProcessor and the following Groovy code:

def data = new groovy.json.JsonSlurper().parse(prev.getResponseData())

data.glossary.GlossDiv.GlossList.GlossEntry.Acronym = 'SGML 1234'

vars.put('data', new groovy.json.JsonBuilder(data).toPrettyString())

refer generated value as ${data} where required

More information:

  • Related