Not sure what do you mean by "rooms objects" but JSON can be created using any suitable JSR223 Test Element <https://jmeter.apache.org/usermanual/best-practices.html#jsr223> and JsonBuilder <http://docs.groovy-lang.org/next/html/gapi/groovy/json/JsonBuilder.html>.

Example code:

def payload = [:]

payload.put('id','123-456')
payload.put('correlationId','123-098-789')

def rooms = []

1.upto(2,{ def room = [id:"r$it",rNumber: it,location: [id:"L1",city:"Munich"]]
    rooms.add(room)
})

payload.put('rooms',rooms)

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

The generated value can be referred as *${payload}* later on where required.

More information:

 * Apache Groovy - Parsing and producing JSON
   <https://groovy-lang.org/processing-json.html>
 * Apache Groovy - Why and How You Should Use It
   <https://www.blazemeter.com/blog/groovy-new-black>


On 5/24/2022 10:43 AM, Pat Gell wrote:
Hello,

I'm stuck again with Jmeter tests.
I want to send a JSON text message via JMSPublisher to ActiveMQ.
Example Payload:
*{*
*  "id": "123-456",*
*  "correlationId": "123-098-789",*
*  "rooms": [*
*    {*
*      "id": "r1",*
*      "rNumber": 321,*
*      "location": {*
*        "id": "L1",*
*        "city": "Munich"*
*      }*
*    },*
     *{*
*      "id": "r2",*
*      "rNumber": 42,*
*      "location": {*
*        "id": "L1",*
*        "city": "Munich"*
*      }*
*    }*
*  ]*
*}*

Is it possible to create the payload with multiple room objects via script
(e.g groovy)?
Could you provide an example how to script the rooms objects in the
JMSPublisher payload?

Best regards,
Patrick

Reply via email to