问题:带重音字符的JSON映射文本
我对JSON有一个问题。我有一个RESTAPI来返回对象列表。此对象包含带有enter和title(ó)的文本,并且文本包含“\U00f3n”、“\n”,我无法将其映射到文本 我将结果转换为JSON,如下所示:问题:带重音字符的JSON映射文本,json,swift,Json,Swift,我对JSON有一个问题。我有一个RESTAPI来返回对象列表。此对象包含带有enter和title(ó)的文本,并且文本包含“\U00f3n”、“\n”,我无法将其映射到文本 我将结果转换为JSON,如下所示: let jsonResult: AnyObject! = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &err) fun
let jsonResult: AnyObject! = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &err)
func parseNew(pNew: AnyObject)->New
{
if let description = pNew["Text"] as? String
{
newRetorno.setText(description)
}
}
我将结果映射到如下文本:
let jsonResult: AnyObject! = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &err)
func parseNew(pNew: AnyObject)->New
{
if let description = pNew["Text"] as? String
{
newRetorno.setText(description)
}
}
你想用这个“newretrono.setText”做什么?此外,您的语法被破坏。第一行应该是“let jsonResult=NSJSONSerialization(数据:数据,选项:.MutableContainers,错误:&err)”@JohnDifool???OP的语法有效,而你的语法无效。在操场登记。啊!在XCode Beta 7上运行的美妙之处!苹果显然在继续完善ObjC和Swift之间的桥接API。@johndibook行newretrono.setText()是另一回事,不管怎样。检查是否处理包含nl的JSON。