I'm looking on how to construct or create a son object from a list of class objects.
I have a Category class which look like :
class Category {
var Code: Int?
var Label: String?
init(Code: Int, Label: String) {
self.Code = Code
self.Label = Int
}
}
and then I have a list of category var categories = [Category]()
and then I append my list like this :
categories.append(5,"Shoes")
How can I construct a json object which will look like this :
{
"List":[
{
"Code":"5",
"Label":"Shoes"
},
....
]
}