As far as I got your requirement it would be something like this:
def payload = []
1.upto(vars.get('foo_matchNr') as int, { roomId ->
def startValue = 9173
1.upto(300, block -> {
def entry = [roomId: vars.get('foo_' + roomId), daysCount: startValue as String, a: "F", x: "0", t: "0", y: "-", l: "0"]
startValue = startValue + 1
payload.add(entry)
})
})
vars.put('payload', new groovy.json.JsonBuilder(payload).toPrettyString())
More information: