I am trying to build a JSON in Python. I want to send it to Slack.
xxdata = []
xxdata.append("Option A")
xxdata.append("Option B")
data=[]
for xx in xxdata:
item = {"text": {
"type": "plain_text",
"text": xx,
"emoji": True
}}
data.append(dict(item))
jsonData=json.dumps(data)
This is how I am sending it to slack:
{
"type": "section",
"block_id": "Settings1",
"text": {
"type": "mrkdwn",
"text": ":gear: *MAIN*\nSelect your main group"
},
"accessory": {
"type": "static_select",
"placeholder": {
"type": "plain_text",
"text": "Option A",
"emoji": True
},
"options": jsonData,
"action_id": "NotificationSelect"
}
However, when it is sent to Slack - I am getting additional quotation marks before and after the option data:
{
"type": "section",
"block_id": "Settings1",
"text":
{
"type": "mrkdwn",
"text": ":gear: *MAIN*\nSelect your main group"},
"accessory": {
"type": "static_select",
"placeholder": {
"type": "plain_text",
"text": "Option A",
"emoji": true},
"options": "[
{
"text":
{"type": "plain_text",
"text": "Option A",
"emoji": true}
},
{"text":
{"type": "plain_text",
"text": "Option B",
"emoji": true}
}
]",
"action_id": "NotificationSelect"}},
This causing Slack to fail. what am I doing wrong? If I am removing these quotation marks everything works fine.