我有以下代码
AddTicketCommand addTicketCommand = new AddTicketCommand(request.JSON)
JsonBuilder jsonBuilder = new JsonBuilder()
jsonBuilder {
ticket {
subject addTicketCommand.subject
requester {
name currentUser?.name
email currentUser?.emailAddress
}
comment {
body addTicketCommand.comment
}
custom_fields {
[
{
id 21857727
value addTicketCommand.zenRequestType
},
{
id 21854146
value addTicketCommand.zenProductId
}
]
}
}
}
addTicketCommand 对象在第 2 行不为空,但在 JsonBuilder 闭包中未定义。不能从闭包中访问 groovy 中的局部变量吗?