Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
问题:带重音字符的JSON映射文本_Json_Swift - Fatal编程技术网

问题:带重音字符的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

我对JSON有一个问题。我有一个RESTAPI来返回对象列表。此对象包含带有enter和title(ó)的文本,并且文本包含“\U00f3n”、“\n”,我无法将其映射到文本

我将结果转换为JSON,如下所示:

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。