-
Notifications
You must be signed in to change notification settings - Fork 0
couldn't encode Dictionary of type Dictionary<String,JSON> #1
Description
i have a struct name TimelineDataStruct in which there is a stored property of type Dictionary<String,JSON>.Where JSON is the other struct(JSON is struct from the well known library SwiftyJson ) . but an error occure while encoding variable of type Dictionary<string,JSON>
"Argument type 'Dictionary<String, JSON>' does not conform to expected type 'AnyObject"
`struct TimelineDataStruct{
var coordinates:NSString? = "hellow"
let truncated:Bool?
let created_at:NSString?
let favorited:Bool?
let id_str:NSString?
let in_reply_to_user_id_str:NSString?
var entitiesStrct = Dictionary<String,JSON>()
}
init(coordinates:String?,
truncated:Bool?,
created_at:String?,
favorited:Bool?,
id_str:String?,
in_reply_to_user_id_str:String?,
entitiesStrct:Dictionary<String,JSON>?)
{
self.coordinates = coordinates
self.truncated = truncated
self.created_at = created_at
self.favorited = favorited
self.id_str = id_str
self.in_reply_to_user_id_str = in_reply_to_user_id_str
self.entitiesStrct = entitiesStrct!
}
private enum EncoderKeys : String {
case coordinates
case truncated
case created_at
case favorited
case id_str
case in_reply_to_user_id_str
case entitiesStrct
}
func encode(encoder: FierceEncoder) {
encoder.encodeObject(self.coordinates!, key: EncoderKeys.coordinates.rawValue)
encoder.encodeObject(self.truncated!, key: EncoderKeys.truncated.rawValue)
encoder.encodeObject(self.created_at!, key: EncoderKeys.created_at.rawValue)
encoder.encodeObject(self.favorited!, key: EncoderKeys.favorited.rawValue)
encoder.encodeObject(self.id_str!, key: EncoderKeys.id_str.rawValue)
encoder.encodeObject(self.entitiesStrct, key: EncoderKeys.entitiesStrct.rawValue)
}`
encoder.encodeObject(self.entitiesStrct, key: EncoderKeys.entitiesStrct.rawValue)
this line shows error
"Argument type 'Dictionary<String, JSON>' does not conform to expected type 'AnyObject'"