let email = MUser.sharedInstance.getUserEmail()
let json = [
"listIds": [""],
"contacts": [{ "email" : "\(email)" }]
];
运行上面的代码时出现错误Consecutive statements on a line must be separated by ';'
。我究竟做错了什么?
答案 0 :(得分:1)
问题出在字典email: email
上,其中{
,}
不是公认的关键字。您可以这样定义json:
let json = [
"""
"listIds": [""],
"contacts": [ {"email" : "\(email)" }]
"""
];
或者如果您希望在与代码的联系中构造字典,则可以执行以下操作:
let json = [
"listIds": [""],
"contacts": [[ "email" : "\(email)" ]]
];