//
//  UserParser.swift
//  NearbyStores
//
//  Created by DT Team on 5/20/18.
//  Copyright © 2018 Amine. All rights reserved.
//

//
//  JobParser.swift
//  AppTest
//
//  Created by DT Team on 5/15/18.
//  Copyright © 2018 Amine. All rights reserved.
//

import UIKit
import SwiftyJSON

class CFieldParser: Parser {
    
    
    func parse(id: Int) -> [CField] {
        
        var list = [CField]()
        
    
        if let myResult = self.result {
            
        
           
            // If json is .Dictionary
       
            
            
            if myResult.count > 0 {
                
                let size = myResult.count-1
                
                for index in 0...size {
                    
                    let object = myResult[index]
                    
                  
                    let myObject = CField()
                    
                    myObject.id = "\(id):\(object["label"]):\(object["type"])"
                    myObject.label = object["label"].stringValue
                    myObject.type = object["type"].stringValue
                    myObject.order = object["order"].intValue
                    myObject.step = object["step"].intValue
                    myObject.required = object["required"].intValue
                
                
                    list.append(myObject)
                    
                    
                }
                
                
            }
            
            
            
            return list
        }
        
        return []
    }
    
    
   
    
}



