为了使用Iris Go发送此JSON
{
"response_type": "in_channel",
"text": "It's 80 degrees right now.",
"attachments": [
{
"text":"Partly cloudy today and tomorrow"
}
]
}
我正在尝试这个但是没有工作
ctx.JSON(iris.Map{
"text": "It's 80 degrees right now.",
"response_type": "in_channel",
"attachments":[{ "text": "Partly cloudy today and tomorrow" }],
})
因为附件行
中出现以下错误syntax error: unexpected {, expecting expression
你知道怎么解决吗?
答案 0 :(得分:1)
在Go代码中,您没有为数组或其元素指定类型。假设您希望它为iris.Map
:
ctx.JSON(iris.Map{
"text": "It's 80 degrees right now.",
"response_type": "in_channel",
"attachments": []iris.Map{iris.Map{ "text": "Partly cloudy today and tomorrow" }},
})