I have a struct and I want to convert that into Dictionary with properties as Key and their value as Value but the key should not be the property name but something different i.e. shopping_list_id
OR shopping_list_name
.
struct AddItemToEvent {
var key: String
var shoppingListId: String //shopping_list_id
var shoppingListName: String //shopping_list_name
var commonName: String
var storeCode: String
var sourceType: String
var sourceId: String
var isDefaultList: String
var storeLocation: String
// shopping_list_id, shopping_list_name, common_name, store_code, source_type (offer, promotion, normal, favourite), source_id, default_list, store_location, client_id
}
I need to have a method for struct getDictionaryEquivalent()
which can result something like ["shopping_list_name":"", "shopping_list_id": "", ......]