Nice lib, but I have problem when use that to parse json from string
let stringData:NSString = "{\"msgCode\":1,\"msgContent\":\"Success\",\"result\":{\"listThread\":[{\"id\":\"14588730530526otdw\",\"threadId\":\"1457965565616y5Blg\",\"content\":\"comment\",\"status\":0,\"timeCreate\":1458873053052,\"userId\":\"admin\"},{\"id\":\"14588382362644XDaF\",\"threadId\":\"1457965565616y5Blg\",\"content\":\"sdafsd gsdf\",\"status\":0,\"timeCreate\":1458838236264,\"userId\":\"null\"}],\"total\":16},\"timeServer\":1459236558851,\"s\":0}";
and I used lib like that
let jsonData:NSData = stringData.dataUsingEncoding(NSUTF8StringEncoding)!; do{ let jsonDic = try NSJSONSerialization.JSONObjectWithData(jsonData, options: .MutableContainers) as! [String: AnyObject]; guard let testObj = TestObj(json: jsonDic)else{ print("[\(NSURL(fileURLWithPath:#file).lastPathComponent! as String): \(#line)] >> \(#function): ERROR"); return } }catch let error{ NSLog("[ %@ : %d] %@ > ERROR: %@", #file, #line, #function, "\(error)"); }
with TestObj as file attachment
TestObjc.txt
But when i run it my testObj.result.listThread.count == 0? Can't get any object from listThread?
and when i try with json
let testData = ["msgCode":1,"msgContent":"Success","result":["listThread":[["id":"14588730530526otdw","threadId":"1457965565616y5Blg","content":"comment","status":0,"timeCreate":1458873053052,"userId":"admin"],["id":"14588382362644XDaF","threadId":"1457965565616y5Blg","content":"sdafsd gsdf","status":0,"timeCreate":1458838236264,"userId":"null"]],"total":16],"timeServer":1459236558851,"s":0]
it's fail too!
Thanks for lib!