Json: 解析 +

错误滴

        let jsonData = try! NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers)
        print("_______________________________________________________________________________________________________________")
        print(jsonData)
        
        let dictionary = jsonData as? NSDictionary
        let findModel = FindModel()
        
        if (dictionary!.isKindOfClass(NSDictionary.self) == true ){
        
            findModel.setValuesForKeysWithDictionary((dictionary as! Dictionary))
            
            let dataDictionary = findModel.data as! Dictionary
            
            let dataModel = FindDataModel()
            
            dataModel.setValuesForKeysWithDictionary(dataDictionary)
            
            let baseInfoDictionary = dataModel.baseInfo as! Dictionary
            
            let baseInfoModel = FDataBaseInfoModel()
            
            baseInfoModel.setValuesForKeysWithDictionary(baseInfoDictionary)
            
            
            
        
            dataModel.baseInfo = baseInfoModel
            findModel.data = dataModel
            
    
        }
    
    
        return findModel

从上往下 ,是不行滴。

必须 ,自下而上。


let jsonData = try! NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers)
        
        let dicionary = jsonData as! Dictionary
        
        let findModel = FindModel()
        
        
        findModel.setValuesForKeysWithDictionary(dicionary)
        
        let dataModel = FindDataModel()
        
        let dataDictionary = dicionary["data"] as! Dictionary
        
        dataModel.setValuesForKeysWithDictionary(dataDictionary)
        
        let baseInfoModel = FDataBaseInfoModel()
        
        let baseInfoDictionary = dataDictionary["baseInfo"] as! Dictionary
        
        baseInfoModel.setValuesForKeysWithDictionary(baseInfoDictionary)
        
        dataModel.baseInfo = baseInfoModel
        findModel.data = dataModel
        print("***********************************************************************************************")
        print(findModel)
        
        
        
        
        
        
        return findModel









你可能感兴趣的:(Json: 解析 +)