json解析器不起作用?

时间:2015-03-23 05:02:24

标签: json parsing swift

这是我的代码,一切正常,在我从服务器获取数据后,我的代码不适用于解析部分。 奇怪的是,它正在处理一些数据,而不是与另一个数据合作 我检查我的数据,我有数据,因为我用utf8encoding将我的数据更改为字符串,它是完美的但我的解析器钢不起作用:((

func connection(connection: NSURLConnection!, didReceiveData data: NSData!){


    var someString = NSString(data: data, encoding: NSUTF8StringEncoding)!

    var someData = someString.dataUsingEncoding(NSUTF8StringEncoding)!

    println(NSString(data:someData , encoding: NSUTF8StringEncoding)!)


    let jsonObject : AnyObject?  = NSJSONSerialization.JSONObjectWithData(data, options:   NSJSONReadingOptions.AllowFragments , error: &jsonError )

,错误是:

Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Unexpected end of file while parsing object.) UserInfo=0x7fba6ad5c690 {NSDebugDescription=Unexpected end of file while parsing object.}
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Garbage at end.) UserInfo=0x7fba6af7b690 {NSDebugDescription=Garbage at end.}

0 个答案:

没有答案