//
//	DensityResult.swift
//
//	Create by Javen Zhang on 29/3/2018
//	Copyright © 2018. All rights reserved.
//	Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport

import Foundation 
import SwiftyJSON


class DensityResult : NSObject, NSCoding{

	var rows : [DensityRow]!


	/**
	 * Instantiate the instance using the passed json values to set the properties values
	 */
	init(fromJson json: JSON!){
		if json.isEmpty{
			return
		}
		rows = [DensityRow]()
		let rowsArray = json["rows"].arrayValue
		for rowsJson in rowsArray{
			let value = DensityRow(fromJson: rowsJson)
			rows.append(value)
		}
	}

	/**
	 * Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
	 */
	func toDictionary() -> [String:Any]
	{
		var dictionary = [String:Any]()
		if rows != nil{
			var dictionaryElements = [[String:Any]]()
			for rowsElement in rows {
				dictionaryElements.append(rowsElement.toDictionary())
			}
			dictionary["rows"] = dictionaryElements
		}
		return dictionary
	}

    /**
    * NSCoding required initializer.
    * Fills the data from the passed decoder
    */
    @objc required init(coder aDecoder: NSCoder)
	{
         rows = aDecoder.decodeObject(forKey: "rows") as? [DensityRow]

	}

    /**
    * NSCoding required method.
    * Encodes mode properties into the decoder
    */
    func encode(with aCoder: NSCoder)
	{
		if rows != nil{
			aCoder.encode(rows, forKey: "rows")
		}

	}

}