0

I have a problem with JSON. I have a Rest API to return a list of objects. This object have text with enter and tittle (ó) and the text have "\U00f3n", "\n", I can't map this to a text.

I convert the result in JSON like this:

let jsonResult: AnyObject! = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &err)

I map the result to text like this:

func parseNew(pNew: AnyObject)->New 
{
  if let description = pNew["Text"] as? String
  {
      newRetorno.setText(description)
  }
}
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Carolina
  • 437
  • 3
  • 18
  • What are you trying to do with this "newRetorno.setText"? Additionally, your syntax is broken. The first line should be "let jsonResult = NSJSONSerialization(data: data, options: .MutableContainers, error: &err)" – John Difool Jun 18 '15 at 01:59
  • @JohnDifool ??? OP's syntax is working, yours is not. Check in a Playground. – Eric Aya Jun 18 '15 at 08:22
  • Ah! The beauty of running on XCode Beta 7! Apple apparently continues to polish their bridged API between ObjC & Swift. – John Difool Jun 18 '15 at 13:43
  • @JohnDifool the line newRetorno.setText() is other thing, no matter – Carolina Jun 18 '15 at 17:07
  • Got it. check http://stackoverflow.com/questions/11591784/parsing-json-containing-new-line-characters for handling JSON which include nl. – John Difool Jun 19 '15 at 01:35

0 Answers0