I want create encodable struct request for the following JSON
{"Symbols":[{"Name":"AAS1"},{"Name":"ASSD"}],"NoOfSymbols":2,"msgtype":15}
I tried to create but getting error.Type 'SymbolName' does not conform to protocol 'Encodable'.Given my tried struct.
struct RequestData:Encodable{
let Symbols:[SymbolName]
let NoOfSymbols:Int
let msgtype: Int
}
struct SymbolName:Encodable{
let Name : [String:Any]
}
Anycannot conform toEncodablehence the error. But it seems you don´t needSymbolNameat all. Try:This will create the appropriate JSON (array of dictionaries):